include script

function inc(filename)
{
    var body = document.getElementsByTagName('HEAD').item(0);
    script = document.createElement('script');
    script.src = filename;
    script.type = 'text/javascript';
    body.appendChild(script);
}

Give Me Bigger

學網連wretch速度很快,故開發此套件,方便逛相簿,搭配Website: cleaner - WRETCH使用,成效更佳。
版本記錄

// ==UserScript==
// @name        Give Me Bigger
// @description    表格式顯示相簿原圖
// @priority 1
// @version        2011-05-17
// @include        http://www.wretch.cc/album/album.php*
// @include        http://*.pixnet.net/album/set/*
// @include        http://photo.xuite.net/*/*
// ==/UserScript==
GM_registerMenuCommand('Give Me Bigger - Setting columns', settingColumns);
GM_registerMenuCommand('Give Me Bigger - Setting width of images', settingImgWidth);
var siteRule=['www.wretch.cc','pixnet.net','photo.xuite.net'];
var thumbRule=['thumbs\/t','thumb_','_c'];
var thumbRRule=['','','_l'];
var contentRule=['#ad_square','#contentBody','.list_area'];
var linkRule=['td.side a','.thumbImg a','.list_area .photo_info a'];
//Setting columns
function settingColumns() {
    var oldCols=GM_getValue('cols')||2;    //(Default Value:2)
    GM_setValue('cols', prompt('Please enter the columns.', oldCols));
}
//Setting width of images
function settingImgWidth() {
    var oldIW=GM_getValue('imgwidth')||240;    //(Default Value:240)
    GM_setValue('imgwidth', prompt('Please Enter the width(px) of images.', oldIW));
}
//Setting display infomation
function settingInfo() {
    window.infoBlock=document.createElement('p');
        infoBlock.style.position='absolute';
        infoBlock.style.top='10px';
        infoBlock.style.left='50px';
        infoBlock.style.fontSize='1.8em';
    window.curCount=document.createElement('span');    //Current complete images
        curCount.textContent=0;
    window.toaCount=document.createElement('span');    //Amount of all images

    infoBlock.appendChild(curCount);
    infoBlock.appendChild(toaCount);
  
    document.getElementsByTagName('body')[0].appendChild(infoBlock);
    window.oriTitle=document.title;    //Save oringinal title
}
//Counting complete images
function imgReady(){
    curCount.textContent=parseInt(curCount.textContent,10)+1;
    document.title = curCount.textContent + toaCount.textContent;
}
//依據網址找出規則式編號
function chkIndex(){
    for(var i=0;i<siteRule.length;i++)
        if(location.href.indexOf(siteRule[i]) != -1) return i
}
function GMB() {
    settingInfo();
    var ruleIndex=chkIndex();    //規則式編號
    var imgWidth=parseInt(GM_getValue('imgwidth')||240,10)    //圖片寬度
    GM_addStyle('.GMBtd img{max-width:@imgwidthpx}'.replace('@imgwidth',imgWidth));
    var pics=document.querySelectorAll('img[src*="' + thumbRule[ruleIndex].replace('\\','') + '"]');    //全部縮圖
    var picLinks=document.querySelectorAll(linkRule[ruleIndex]);    //圖片超連結
    var cols=parseInt(GM_getValue('cols')||3,10);    //欄數
    var intRows=Math.floor(pics.length / cols);    //整數列
    var leftPics=pics.length % cols;    //剩餘圖片數
    var patt=RegExp('(' + thumbRule[ruleIndex] + ')', 'i');    //原圖規則式
    var htmlCode=[];
    toaCount.textContent=' / ' + pics.length;
    //先處理整數列
    for(var i=0;i<intRows;i++)
    {
        htmlCode[htmlCode.length]='<tr>';
        for(var j=0;j<cols;j++)
            htmlCode[htmlCode.length]='<td class="GMBtd"><a target="_blank" href="' + picLinks[i*cols+j].href + '"><img src="'+ pics[i*cols+j].src.replace(patt,thumbRRule[ruleIndex])+'" /></a></td>';
        htmlCode[htmlCode.length]='</tr>';
    }
    //再處理剩餘圖片
    if(leftPics != 0)
    {
        htmlCode[htmlCode.length]='<tr>';
        for(var k=0;k<leftPics;k++)
            htmlCode[htmlCode.length]='<td class="GMBtd"><a target="_blank" href="' + picLinks[intRows*cols+k].href + '"><img src="'+ pics[intRows*cols+k].src.replace(patt,thumbRRule[ruleIndex])+'" /></a></td>';
        htmlCode[htmlCode.length]='</tr>';
    }
    var tb=document.createElement('table');
    tb.innerHTML=htmlCode.join('');
    tb.id='GMB';
    var oldContent=document.querySelector(contentRule[ruleIndex]);
    oldContent.parentNode.replaceChild(tb,oldContent);
  
    //綁定計算圖片完成數
    var myPics=document.querySelectorAll('#GMB img');
    for(var i=0;myPics[i];++i)
        myPics[i].addEventListener('load',imgReady,false);
    delete htmlCode;
    delete pics;
    delete picLinks;
}
window.addEventListener('DOMContentLoaded',GMB,false);
window.addEventListener('load',function() {document.title=oriTitle},false);

開啟、關閉雙螢幕

此script只適用於WinXP,Win7請使用快捷鍵(win + P)
開啟:
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.Run("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,4");
WScript.Sleep(1000);
WshShell.SendKeys("{TAB}");
WshShell.SendKeys("{DOWN}");
WshShell.SendKeys("{TAB 4}");
WshShell.SendKeys("{ }");
//WshShell.SendKeys("%A");
WshShell.SendKeys("~");

關閉:
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.Run("rundll32.exe shell32.dll,Control_RunDLL desk.cpl,,4");
WScript.Sleep(1000);
WshShell.SendKeys("{TAB}");
WshShell.SendKeys("{DOWN}");
WshShell.SendKeys("{TAB 5}");
WshShell.SendKeys(" ");
WshShell.SendKeys("~");

隱藏資料夾

拖曳資料夾至本批次檔,即可隱藏資料夾
@ECHO OFF
ATTRIB +S +H %1

自動變更IP

判斷目前IP,且自動變更IP
@ECHO OFF
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IPv4"') do set ip=%%b
SET IP=%IP:~1%
IF %IP% == 140.127.22.228 (
    Set ip=140.127.22.219
) ELSE (
    SET ip=140.127.22.228
)
netsh interface ip set address "區域連線" static %IP% 255.255.255.128 140.127.22.253
REM netsh interface ip set dns "區域連線" static 140.127.1.2
REM netsh interface ip add dns "區域連線" static 8.8.8.8
ECHO "Change IP => %IP%"
PAUSE

批次檔編碼

批次檔存檔時,編碼需選用「ANSI」,否則會出現「檔案名稱、目錄名稱或磁碟區標籤語法錯誤。」

KISSRadio 網路音樂台

// ==UserScript==
// @name    KISSRadio 網路音樂台
// @description    顯示歌名於body、title
// @run-at document-end
// @author    NKid
// @version    2011-08-02
// @include    http://www.kiss.com.tw/marquee.php?id=308*
// ==/UserScript==
GM_addStyle('body {background-color:#262629} h1 {text-align:center; margin-top:10%; font-size:5em; color:white;}');
var songName=document.querySelector('td span').innerHTML.replace(/(正在播放|即將播放)<span style=\"font-size:3pt;\"> :<\/span>/,'');
var tb=document.getElementsByTagName('table')[0];
tb.parentNode.removeChild(tb);
document.getElementsByTagName('body')[0].innerHTML='<h1>'+ songName+'</h1>';
//document.title=songName;
setTimeout(function(){location.assign('http://www.kiss.com.tw/marquee.php?id=308' + '&t=' + new Date().getTime() );},30*1000);
function scrlsts() {
    songName = songName.substring(1, songName.length) + songName.substring(0, 1);
    document.title = songName;
    setTimeout(scrlsts, 300);
}
scrlsts();

htmlmarquee - Title Marquee

取得年、月、日、時間

@echo off
echo %%date%%=%date%
echo 年 = %%date:~0,4%% = %date:~0,4%
echo 月 = %%date:~5,2%% = %date:~5,2%
echo 日 = %%date:~8,2%% = %date:~8,2%
echo:
echo %%time%%=%time%
set NowTime=%time: =0%
set hh=%NowTime:~0,2%
set mm=%NowTime:~3,2%
set ss=%NowTime:~6,2%
echo hh=%hh%
echo mm=%mm%
echo ss=%ss%
pause


@ECHO OFF
For /F "tokens=1-3 delims=/ " %%a IN ('DATE /t') DO (SET DATE=%%a-%%b-%%c)
SET NowTime=%time: =0%
ECHO %DATE%-%NowTime:~0,2%-%NowTime:~3,2%-%NowTime:~6,2%
PAUSE


Batch Get Date Time