liu.box

A; 行易有限公司
BQ; <blockquote><cite></cite></blockquote>
BR; <br />
CODE; <code></code>
HR; <hr />
MORE; <!--more-->
IMG; <img src="" />
IMP; <span class="imp"></span>
P; <p></p>
REF; <ref></ref>
SEP; <div class="sep">我是分隔線</div>
SPF; &nbsp;&nbsp;&nbsp;&nbsp;
SPAN; <span></span>
UL; <ul></ul>
OL; <ol></ol>
LI; <li></li>

System.Text.RegularExpressions.Regex.Split

using System.IO;

StreamReader sr = new StreamReader(System.Environment.CurrentDirectory + "\\note.txt");
List<string> listLines = new List<string>();
listLines.AddRange(System.Text.RegularExpressions.Regex.Split(sr.ReadToEnd(), "\r\n"));
sr.Dispose();

FOR 輸出時被空白截斷

因為FOR指令預設分隔符號是空白和Tab,故需複寫。
@ECHO OFF
FOR /f "delims=" %%a in ('DIR *.txt /b') DO ECHO %%a
PAUSE

dos - batch file for loop with spaces in dir name - Stack Overflow

建立捷徑

static void urlShortcutToDesktop(string linkName, string linkUrl)
{
    using (StreamWriter writer = new StreamWriter(rootPath + linkName + "\\" + linkName + ".url"))
    {
        writer.WriteLine("[InternetShortcut]");
        writer.WriteLine("URL=" + linkUrl);
        writer.Flush();
    }
}

pass parameters include and-sign in batch

參數、變數包含『&』符號,記得使用雙引用包起來
ECHO時,請取代成^& SET "a=abc&123&def"
ECHO %a:&=^&%
PAUSE

Quotes, Escape Chars, Delimiters

win7 開機自動連線

  1. 建立Hinet連線
  2. Hinet的撥號選項只留『連線時顯示進度』或者全部都不打勾
  3. 啟動資料夾建立捷徑,C:\Windows\System32\rasphone.exe -d Hinet
  4. 如發生錯誤711:無法載入「遠端存取服務連線管理員」。請檢查下列服務皆需啟動:
    • Telephony
    • Remote Access Connection Manager
    • Remote Access Auto Connection Manager

當您建立網路連線時發生錯誤 711:Cannot Load Remote Access Service Connection Manager 錯誤訊息


Read password from txt file and auto extract RAR file

  1. 取得Part1 RAR檔名
  2. 取得解壓密碼檔名
  3. 讀取解壓密碼 (txt編碼為ANSI)
  4. 執行解壓縮

@ECHO OFF
REM 取得Part1 RAR檔名
FOR /f "delims=" %%a in ('DIR *.rar /oe /b') DO (
SET fisrtFileName=%%a
GOTO getPasswordFileName
)
:getPasswordFileName
REM 取得解壓密碼檔名
FOR /f "delims=" %%a in ('DIR *.txt /oe /b') DO (
SET passwordFileName=%%a
GOTO getPassword
)
:getPassword
REM 讀取解壓縮密碼
REM pw.txt編碼為ANSI
FOR /f "usebackq tokens=1" %%i in ("%passwordFileName%") DO (
SET rarPassword=%%i
GOTO extractFile
)
:extractFile
ECHO RarFileName:%fisrtFileName%
ECHO PwFileName:%passwordFileName%
ECHO Pw:%rarPassword:&=^&%
REM 執行解壓縮
"C:\Program Files\WinRAR\Rar.exe" -p"%rarPassword%" x %fisrtFileName%
FOR /f "delims=" %%a in ('DIR *.url /oe /b') DO (
SET urlFileName=%%a
GOTO renameJPG
)
:renameJPG
REM 重新命名封面
REN *.jpg %urlFileName:.url=%.jpg
PAUSE

檔案總管反向選取

在檔案總管裡,使用Win + A進行反向選取

#x::ExitApp
#IfWinActive ahk_class CabinetWClass
#A:: Send !ei ;編輯(E) → 反向選擇(I)

Middle Paste

  • 在Notepad2裡,按中鍵,每貼上三次,自動多換一行 
  • 在SMG主畫面,按中鍵,貼上下載碼
  • 在SMG新增下載檔案畫面,按中鍵,自動貼上剪貼簿內容且確定

#IfWinActive ahk_class Notepad2U
MButton::
Send ^v
Send {Enter}
L++
IF(L =3)
{
    Send {Enter}
    L=0
}
Return
#IfWinActive ahk_class TAddDownloads.UnicodeClass
MButton::
Send {TAB 6}
Send E:\%Clipboard%
Send {Enter}
Return
#IfWinActive ahk_class TMainForm.UnicodeClass
MButton::
Send {F4}
Return
In this paper:表明論文闡述了什麼觀點
In this study:表述在研究中做了什麼工作、獲得什麼成果
In this paper 與 In this study 的區別 - womendu - ITeye技術網站

Marquee 跑馬燈

var scrl='Test String';
function scrlsts() {
    scrl = scrl.substring(1, scrl.length) + scrl.substring(0, 1);
    document.title = scrl;
    setTimeout(scrlsts, 300);
}
scrlsts();

HTML Marquee

Shoudian Url Redirect

// ==UserScript==
// @name           shoudian URL Redirect
// @description    shoudian URL Redirect
// @include        http://www.shoudiancn.com/*
// @include        http://www.shoudian.org/*
// @include        http://shoudiancn.com/*
// ==/UserScript==
location.assign('http://www.shoudian.com' + location.pathname + location.search);

remove an inline onclick attribute

element.setAttribute ("onclick", null);
javascript - How can I remove an inline onclick attribute with a bookmarklet? - Stack Overflow

event.preventDefault

function stopDefAction(evt) {
  evt.preventDefault();
}

event.preventDefault - MDN Docs

event.target

function showTagName(e)
{
    alert(e.target.tagName);
    e.preventDefault();
}
window.addEventListener('click',showTagName,false);

event.target - MDN Docs

無法升級Windows 7 SP1

主因 :"C:\Windows\System32\DriverStore\FileRepository",內容缺失導致升級系統失敗。

方法一:
  1. Imagex
  2. imagex /apply G:\sources\install.wim 4 D:\123
    PS:首先注意空格 G 為安裝光碟所在光碟機機
              4代表旗艦版 (1:hb 2:hp 3:pro 4:u)
              D:\123 表示複製到D槽123資料夾中 保證此資料空間在7G以上
  3. FileRepository 複製出來,換給系統下的FileRepository

方法二:
  1. Win7光碟
  2. 找到install.wim
  3. 使用7zip解壓縮DriverStore
  4. FileRepository 複製出來,換給系統下的FileRepository

無法升級Windows 7 SP1之解決方案.....-Hermes的平凡之子-無名小站網誌
打開WIM文件並提取系統文件最簡單最有效的方法

Quick Tetris

因為懶得動滑鼠按按鈕,故寫AHK用鍵盤按
目前功能如下:
  • W鍵,自動置中視窗
  • S鍵,Start (Sprint、2P)
  • A鍵,Play Again (Sprint、2P)
  • R鍵,Restart (Sprint)

#IfWinActive ahk_class Chrome_WidgetWin_1
$W::ResizeWin(1075,1052)

;Sprint Restart
#IfWinActive ahk_class Chrome_WidgetWin_1, Tetris Sprint
$R::
Send {Esc}
ControlClick, x710 y570
Return

;Sprint Play Again
#IfWinActive ahk_class Chrome_WidgetWin_1, Tetris Sprint
$A::ControlClick, x258 y558

;Sprint Start
#IfWinActive ahk_class Chrome_WidgetWin_1, Tetris Sprint
$S::ControlClick, x722 y503

;2P Start
#IfWinActive ahk_class Chrome_WidgetWin_1, Battle 2P
$S::ControlClick, x332 y345

;2P Play Again
#IfWinActive ahk_class Chrome_WidgetWin_1, Battle 2P
$A::ControlClick, x258 y560

ResizeWin(Width = 0,Height = 0)
{
    WinGetPos,X,Y,W,H,A
    If %Width% = 0
        Width := W
    If %Height% = 0
        Height := H
   
    X:=(A_ScreenWidth - Width) / 2
    Y:=0
    WinMove,A,,%X%,%Y%,%Width%,%Height%
}

StringSplitOptions.RemoveEmptyEntries

string str = "aaa,bbb,ccc,,ddd";
string[] strAry = str.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < strAry.Length; i++)
    Console.WriteLine(strAry[i]);

String.Split 方法 (Char[], StringSplitOptions) (System)
用 split() 分割字串 : 文章 : 格子樑 | 艾倫 郭 | AllenKuo.com

Graphviz 中文字型

  1. 開啟Graphviz\etc\fonts\fonts.conf
  2. 找到
    <dir>#FONTDIR#</dir>
  3. 更改
    <dir>C:\WINDOWS\Fonts</dir>

  4. digraph g {
         node[fontname = "Microsoft JhengHei"];
         "中文" -> "英文";
    }

在 Windows 上設定 Graphviz 中文字型 - electronic_blue

Calling a Batch in the work directory

Runtime.getRuntime().exec(System.getProperty("user.dir") + "\\BATCH.bat");
Calling a Batch file from Java using the exec command.

[FireGestures] Paste and Go

const IN_NEW_TAB = true;
const IN_BACKGROUND = false;

var str = readFromClipboard();
var s='http://www.google.com.tw/search?q=@search&oe=utf-8&hl=zh-TW';
if (!str) return;
if (!/^(\s*)http(s?):\/\//.test(str)) str=s.replace('@search',encodeURIComponent(str));
if (IN_NEW_TAB)
gBrowser.loadOneTab(str, null, null, null, IN_BACKGROUND, false);
else
gBrowser.loadURI(str);

FireGestures :: Get Scripts -> Open URL from Clipboard
求高手將Paste and go ,Paste and search這兩個腳本合二為一 - 閱讀主題 :: Mozilla Firefox中文社區

Command-line reference A-Z

Command-line reference A-Z

WebClient download HTML source code

using System;
using System.IO;
using System.Net;
using System.Text;

string source;
using (WebClient wc=new WebClient())
{
    //方法1:使用串流讀取
    StreamReader sr=new StreamReader(wc.OpenRead("http://tw.yahoo.com"),Encoding.UTF8);
    source=sr.ReadToEnd();
    sr.Close();
    sr.Dispose();
           
    //方法2:使用webclient.DownloadString()
    //source=wc.DownloadString("http://tw.yahoo.com");
}
Console.WriteLine(source);

C# Array.ForEach Method

string[] testAry = { "Apple","bbb", "Ben", "aaa" };
Array.Sort(testAry);
Array.ForEach(testAry, delegate(string str) { Console.WriteLine(str); });

Common Expression

Table Expression = <table[^>]*>(.*?)</table>
Header Expression = <th[^>]*>(.*?)</th>
Row Expression = <tr[^>]*>(.*?)</tr>
Column Expression  = <td[^>]*>(.*?)</td>
Textarea Expression = <textarea[^>]*>(.*?)</textarea>

HashCode x Random

Random Counter = new Random(Guid.NewGuid().GetHashCode());
[C#]不同的Random物件給予不同的亂數種子 - Level Up- 點部落

UTF8Encoding And BOM

//Write with BOM
File.WriteAllText(path, content,new UTF8Encoding(true));

//Write with no BOM
File.WriteAllText(path, content,new UTF8Encoding(false));

UTF8Encoding 建構函式 (Boolean) (System.Text)
KB-UTF8Encoding And BOM - 黑暗執行緒

M01 Category Fix

// ==UserScript==
// @name    M01 Category Fix
// @description    修改M01 category.php的快捷連結
// @run-at document-end
// @author    NKid
// @version    2011-07-10
// @include    http://www.mobile01.com/category.php?id=*
// ==/UserScript==
var htmlCode='<ul class="lv02" style="visibility: hidden; display: none;">@lis</ul>';
var s=document.getElementById('shortcut-content').innerHTML;
s=s.replace(/\s\|\s/g,'');
s=s.replace(/(<a\s.*?href=.*?>)(.*?)(<\/a>)/g,'<li>$1$2$3</li>');
htmlCode=htmlCode.replace('@lis',s);
document.querySelector("#top-menu a[style]").parentNode.innerHTML+=htmlCode;
unsafeWindow.$(".sf-menu").superfish({
        delay: 500,
        pathClass: 'current',
        dropShadows: false,
        speed: 100,
        autoArrows: false
    });

two select elements exchange single option

W3C ver.
var s1=document.getElementById('s1');
var s2=document.getElementById('s2');

function AddDelOption(a,b) {
  var txt=a.options[a.selectedIndex].value;
  b.options.add(new Option(txt,txt));
  a.remove(a.selectedIndex);
}
document.getElementById('addBtn').addEventListener('click',function(){AddDelOption(s1,s2);},false);
document.getElementById('delBtn').addEventListener('click',function(){AddDelOption(s2,s1);},false);

jQuery ver. var s1=document.getElementById('s1');
var s2=document.getElementById('s2');

function AddDelOption(a,b) {
  var txt=$(a).val();
  $(b).append("<option value=\"" + txt + "\">" + txt + "</option>");
  a.remove(a.selectedIndex);
}

$('#addBtn').click(function(){AddDelOption(s1,s2);});
$('#delBtn').click(function(){AddDelOption(s2,s1);});

Creating URL shortcut

private void urlShortcutToDesktop(string linkName, string linkUrl)
{
    string deskDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);

    using (StreamWriter writer = new StreamWriter(deskDir + "\\" + linkName + ".url"))
    {
        writer.WriteLine("[InternetShortcut]");
        writer.WriteLine("URL=" + linkUrl);
        writer.Flush();
    }
}

C# - Creating URL shortcut to desktop

How to pass arguments to addEventListener listener function?

function test(a,b) {
    return a+b;
}
someObj.addEventListener("click",function() { test(5,20); },false);

javascript - How to pass arguments to addEventListener listener function? - Stack Overflow

ASP.NET 2.0 AJAX Extensions run in IIS7

  1. ASPAJAXExtSetup
  2. 取出System.Web.Extensions.Design.dll、System.Web.Extensions.dll
  3. 放入網站Bin資料夾

Redirect to static HTML (Discuz!)

適用於Discuz!論壇,從動態網頁轉至靜態網頁,AutoPagerize才有作用
javascript:
(function(){
  var tid=/tid=(\d*)/.exec(location.search)[1];
  var page=(/page=(\d*)/.test(location.search)[1])?/page=(\d*)/.exec(location.search)[1]:1;
  location.assign('thread-'+tid+'-'+page+'-1.html');
}
)()

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

移動.jpg至上一層目錄

移動.jpg至上一層目錄
FORFILES /S /M *.jpg /C "cmd /c move @file .."

FDZ Keyword Hightlight

FDZ Title Keyword Hightlight,加入下列兩項功能

// ==UserScript==
// @name    FDZ Keyword Hightlight
// @description    自動高亮文章標題關鍵字
// @author    NKid
// @version    2011-04-24
// @run-at document-end
// @include    http://forum.fdzone.org/forumdisplay.php?fid=*
// @include    http://forum.*.fdzone.org/forumdisplay.php?fid=*
// ==/UserScript==
GM_registerMenuCommand('FDZ Keyword Hightlight - Setting Keywords', settingKeywords);
GM_registerMenuCommand('FDZ Keyword Hightlight - Keywords List', listKeywords);
GM_registerMenuCommand('FDZ Keyword Hightlight - Setting Authors', settingAuthors);
GM_registerMenuCommand('FDZ Keyword Hightlight - Authors List', listAuthors);
GM_registerMenuCommand('FDZ Keyword Hightlight - Open Link in New Tab', openNewTab);
//GM_registerMenuCommand('FDZ Title Find RegExp - DEL', DEL);
GM_addStyle('.GM_gotit {color:#000;background-color:#FBED73;-moz-border-radius:3px;padding:0 2px;}');    //Highlight Keyword Style
GM_addStyle('#GM_newtab {-moz-border-radius: 3px; color: #000000; cursor: pointer; font-size: 10px; height: 10px; position: fixed; right: 3px; top: 3px; width: 10px;} .GM_newtabOn {background-color: #00FF00} .GM_newtabOff {background-color: #FF0000}');    //NewTab State
/*function DEL() {GM_deleteValue("keywords");}*/
var tar=GM_getValue('newtab');    //new tab state
//setting Keywords
function settingKeywords() {
    var KWs = (decodeURI(GM_getValue("keywords")) == 'undefined') ? '' : decodeURI(GM_getValue("keywords"));
    var newKWs = prompt('Please Enter the Keywords.\n(use commas to separate)', KWs).split(',');
    newKWs.sort(descStrLen);
    GM_setValue("keywords", encodeURI(newKWs.join()));
    refreshPage();
}
//list Keywords
function listKeywords() {
    var listKWs = decodeURI(GM_getValue("keywords")).split(',');
    alert(listKWs.join('\n'));
}
//setting Authors
function settingAuthors() {
    var ARs = (decodeURI(GM_getValue("authors")) == 'undefined') ? '' : decodeURI(GM_getValue("authors"));
    var newARs = prompt('Please Enter Authors\' names.\n(use commas to separate)', ARs).split(',');
    newARs.sort(descStrLen);
    GM_setValue("authors", encodeURI(newARs.join()));
    refreshPage();
}
//list Authors
function listAuthors() {
    var listARs = decodeURI(GM_getValue("authors")).split(',');
    alert(listARs.join('\n'));
}
//Open articles in new tab
function openNewTab() {
    GM_setValue("newtab", confirm("Open articles in new tab?"));
    refreshPage();
}
//sort function (by string length)
function descStrLen(a, b) {
    if (a.length < b.length) return 1;
}
//Message Refresh Page
function refreshPage() {
    alert('Please Refresh Page.');
}
function toRegExpArray(oriArray) {
    //把關鍵字array轉換成RegExp Array
    var reArray = new Array(); //RegExp Array
    for (var i = 0; i < oriArray.length; i++) {
        reArray.push(new RegExp('(' + oriArray[i] + ')','ig'));
    }
    return reArray;
}
function main() {
    //文章標題、描述
    var KWs = decodeURI(GM_getValue('keywords')).split(',');    //keywords array
    var titles = document.querySelectorAll('span[id^=thread_]');    //all articles' title
    var descs=document.querySelectorAll("[id^='desc_']");    //all articles' description
    //作者
    var ARs = decodeURI(GM_getValue('authors')).split(',');    //authors array
    var authors=document.querySelectorAll('.author > cite > a');    //all authors
  
    //轉換RegExp Array
    var reKWs=toRegExpArray(KWs);
    var reARs=toRegExpArray(ARs);
    //比對關鍵字
       var i, j, titleStr, descStr,authorStr;
    for (i = 0; i < titles.length; i++) {
        //取出文章標題超連結的文字
        titleStr = titles[i].childNodes[0].innerHTML;
        //比對關鍵字
        for (j = 0; j < reKWs.length; j++) {
            if (reKWs[j].test(titleStr)) titleStr = titleStr.replace(reKWs[j], '<span class=\"GM_gotit\">$1</span>');
        }
        titles[i].childNodes[0].innerHTML = titleStr;
        titles[i].childNodes[0].target=(tar)?"_blank":"";
        titles[i].childNodes[0].href=titles[i].childNodes[0].href.replace(/&i.*/i,'');    //FDZ Article Link Clean
    }
    for (i = 0; i< descs.length; i++) {
        //取出文章描述的文字
        descStr = descs[i].innerHTML;
        //比對關鍵字
        for (j = 0; j < reKWs.length; j++)
            if (reKWs[j].test(descStr)) descStr = descStr.replace(reKWs[j], '<span class=\"GM_gotit\">$1</span>');
        descs[i].innerHTML = descStr;
    }
    for (i = 0; i< authors.length; i++) {
        //取出文章描述的文字
        authorStr = authors[i].innerHTML;
        //比對關鍵字
        for (j = 0; j < reARs.length; j++) {
            if (reARs[j].test(authorStr)) authorStr = authorStr.replace(reARs[j], '<span class=\"GM_gotit\">$1</span>');
        }
        authors[i].innerHTML = authorStr;
    }
}
function newtab() {
    var newtabState = document.createElement("div");
    newtabState.id="GM_newtab";
    newtabState.title="Open articles in newtab ?";
    newtabState.className=(tar)?"GM_newtabOn":"GM_newtabOff";
    document.getElementsByTagName("body")[0].appendChild(newtabState);
    document.getElementById('GM_newtab').addEventListener('click',function(){GM_setValue("newtab", 1-GM_getValue("newtab")); refreshPage(); },false);
}
main();
newtab();

整理索引、回收已刪除空間

When a large amount of data is deleted from the database file it leaves behind empty space, or "free" database pages. This means the database file might be larger than strictly necessary. Running VACUUM to rebuild the database reclaims this space and reduces the size of the database file.
for %%i in (*.sqlite) do sqlite3 %%i VACUUM | echo %%i
FORFILES /M *.sqlite /S /C "cmd /c sqlite3.exe @file VACUUM | ECHO @file"
SQLite Query Language: VACUUM
Mozilla Links 正體中文版: Firefox 3 日漸肥大的收藏庫:減肥法
Vacuum the Stylish SQLite DB - forum.userstyles.org

Pron 104

無法查看此摘要。請 按這裡查看文章。

Get Lotto Win Num

// ==UserScript==
// @name        Get Lotto Win Num
// @description    Get Lotto Win Num
// @include    http://www.taiwanlottery.com.tw/Lotto/Lotto649/history.aspx
// ==/UserScript==
var n=document.querySelectorAll('div > span[id*="_No"]');
var winNumStr='';
for(var i=0;i<n.length;i++)
{
    winNumStr+=n[i].innerHTML + " ";
        if((i+1) % 7 == 0) winNumStr+="\n";
}
alert(winNumStr);

FDZ Encrypt Promotion

// ==UserScript==
// @name           FDZ Encrypt Promotion
// @description    加強解密推廣功能,自動轉址
// @include        http://forum.*.fdzone.org/encryname.php?uid=*
// @include        http://forum.fdzone.org/encryname.php?uid=*
// @include        http://pro.fdzone.org/encryname.php?uid=*
// ==/UserScript==
location.assign("space.php?action=viewpro&uid=" + location.search.replace(/\?uid=/i,""));

Blogger "I wish to continue"

因為Same Origin Policy,所以在cross-domain存取會產生"Permission denied to get property"問題,先轉址至iframe,再進行存取。

// ==UserScript==
// @name    Blogger "I wish to continue"
// @description    Blogger "I wish to continue"
// @author    NKid
// @version    2011-12-10
// @include    http://www.blogger.com/blogin.g?blogspotURL=*
// ==/UserScript==
if (document.querySelector('iframe'))
    location.assign(document.getElementById('injected-iframe').src);
else
    location.assign(document.querySelector('.kd-button-bar a:nth-child(1)').href);


Scripting Iframes - Tutorial and Examples
Why is this javascript getting permission denied? - Stack Overflow

取得IP

Note:不同的OS,需更改IPv4此字串

@ECHO OFF
for /f "tokens=1-2 delims=:" %%a in ('ipconfig^|find "IPv4"') do set ip=%%b
SET IP=%IP:~1%
ECHO %IP%
TIMEOUT 5


command - Batch: get IP address - Stack Overflow

關閉自動更新後不自動重開機延期視窗

  1. gpedit.msc
  2. 電腦設定 → 系統管理範本 → Windows元件 → Windows Update
  3. 有使用者登入時不自動重新開機以完成排定的自動更新安裝 → 已啟用

M01 Gallery List View

  • 自動展開貼圖,並條列顯示
  • 除第一頁之外,皆自動移除圖片區塊

2011-04-09 加入頁碼判斷
2011-04-09 基本架構完成

// ==UserScript==
// @name        M01 Gallery List View
// @description    M01 Gallery List View
// @version        2011-04-09
// @include        http://www.mobile01.com/gallerydetail.php*
// @include        https://www.mobile01.com/gallerydetail.php*
// ==/UserScript==
var pageIndex = parseInt(location.search.replace(/\?.*&p=(\d+)/,'$1'),10);
var gallery = document.getElementById('gallery_tl');
var gContent=document.getElementsByClassName('gallery_content')[0];
if (pageIndex >1)
    gallery.parentNode.removeChild(gallery);
else
{
    var imgs=gallery.querySelectorAll('img');
    var tmp='<img src="@src" /><br />';
    var newHTML='';
    for(var i=0;i<imgs.length;i++)
        newHTML+=tmp.replace('@src',imgs[i].src).replace('thumb','mobile01');
    gallery.innerHTML=newHTML;
}
gContent.parentNode.removeChild(gContent);

Node.removeChild()

var gContent=document.getElementsByClassName('gallery_content')[0];
gContent.parentNode.removeChild(gContent);

Node.removeChild - MDC Doc Center

ReSize Imgs (AutoScale)

javascript:
(function(){
  var img=document.getElementsByTagName('img');
  var MaxWidth=window.outerWidth*0.75;
  var MaxHeight=800;
  for(i=0;i<img.length;i++){
    var HeightWidth=img[i].offsetHeight/img[i].offsetWidth;
    var WidthHeight=img[i].offsetWidth/img[i].offsetHeight;
    if(img[i].offsetWidth>MaxWidth){
      img[i].width=MaxWidth;
      img[i].height=MaxWidth*HeightWidth;
    }
    if(img[i].offsetHeight>MaxHeight){
      img[i].height=MaxHeight;
      img[i].width=MaxHeight*WidthHeight;
    }
  }
}
)()

ReSize Imgs (AutoScale)

新增 Notepad2 至右鍵選單

HKEY_CLASSES_ROOT\*\shell\Notepad2
HKEY_CLASSES_ROOT\*\shell\Notepad2\Command
預設值:"C:\Program Files\Notepad2\Notepad2.exe" "%1"

Add Notepad2 to Windows Vista or XP Right Click Context Menu » My Digital Life

[FireGestures] Resize Browser

if (FireGestures.API_resizeWindow === undefined) {
  FireGestures.API_resizeWindow = function(w, h) {
    window.resizeTo(w, h);
    window.screenX = 0;
    window.screenY = 0;
    this.setStatusText("Resized the window to " + w + " x " + h);
    this.clearStatusText(3000);
  };
}

var currentWidth = window.outerWidth;
var currentHeight = window.outerHeight;

FireGestures.generatePopup(event,
  [
    { label: "640 x 480",  oncommand: "this.API_resizeWindow(640, 480);",  type: "radio", checked: (currentWidth == 640 && currentHeight == 480) },
    { label: "800 x 600",  oncommand: "this.API_resizeWindow(800, 600);",  type: "radio", checked: (currentWidth == 800 && currentHeight == 600) },
    { label: "1024 x 768", oncommand: "this.API_resizeWindow(1024, 768);", type: "radio", checked: (currentWidth == 1024 && currentHeight == 768) },
    { label: "1280 x 1024", oncommand: "this.API_resizeWindow(1280, 1024);", type: "radio", checked: (currentWidth == 1280 && currentHeight == 1024) }
  ]
);

FireGestures :: Make Scripts
FireGestures :: Get Scripts -> [Popup] Resize Window

雙重逸出序列

錯誤摘要

HTTP 錯誤 404.11 - Not Found

要求篩選模組設定為拒絕包含雙重逸出序列的要求。


解法:
  1. 要求篩選
  2. 編輯功能設定...
  3. 勾選「允許雙重逸出」

設定 IIS 7 中的要求篩選

MIME (Multipurpose Internet Mail Extensions)

7z | application/x-7z-compressed
ts | video/mp2t
tp | video/mp2t
torrent | application/x-bittorrent
kml | application/vnd.google-earth.kml+xml

7z - Wikipedia, the free encyclopedia

Windows 7 傳送到 (Send To)

%APPDATA%/Microsoft/Windows/SendTo
Windows 7加入滑鼠右鍵的快捷列「Send To..(傳送到)」 - MIS2000 Lab.的 ASP.NET 4.0 專題實務/教學與分享- 點部落

關閉Windows 7的自動播放功能

方法一:
  1. gpedit.msc
  2. 電腦設定 → 系統管理範本 → Windows元件 → 自動播放原則
  3. 關閉自動播放 → 已啟用,停用自動播放在:所有磁碟機
  4. AutoRun的預設行為 → 已啟用,預設AutoRun行為:不執行任何AutoRun命令
方法二:
  1. 控制台
  2. 自動播放
  3. 取消勾選「所有媒體與裝置都使用自動播放功能」

教您如何關閉Windows 7的自動播放功能 « 甲胖 ~ 生活+樂趣=意義
開/關「自動播放」由你做主 - 小7聚樂部

Firefox Shortcut

Command : Find As You Type Link
Shortcut : '

Command : Bookmark All Tabs
Shortcut : Ctrl + Shift + D

Command : Add-ons
Shortcut : Ctrl + Shift + A

Keyboard shortcuts | How to | Firefox Help

FORFILES

FORFILES [/P pathname] [/M searchmask] [/S]
         [/C command] [/D [+ | -] {yyyy/MM/dd | dd}]

描述:
    選取一個檔案 (或一組檔案),並在檔案上
    執行命令。這對批次工作很有幫助。

參數清單:
    /P    pathname      表示要開始搜尋的路徑。
                        預設資料夾是目前的
                        目錄 (.)。

    /M    searchmask    根據 searchmask 搜尋檔案。
                        預設的 searchmask 是 '*'。

    /S                  指示 forfiles 遞迴搜尋
                        子目錄。例如 "DIR /S"。

    /C    command       表示每個檔案要執行的命令。
                        命令字串應該包含在雙括號
                        之間。

                        預設的命令是 "cmd /c echo @file"。

                        下列變數可以使用於命令字串:

                        @file    - 傳回檔案的名稱。
                        @fname   - 只傳回檔案的名稱,
                                   不傳回副檔名。
                        @ext     - 只傳回檔案的
                                   副檔名。
                        @path    - 傳回檔案的完整路徑。
                        @relpath - 傳回檔案的相對
                                   路徑。
                        @isdir   - 如果檔案類型是目錄的話,
                                   傳回 "TRUE",如果是檔案
                                   的話,傳回 "FALSE"。
                        @fsize   - 傳回檔案的大小,
                                   單位是位元組。
                        @fdate   - 傳回檔案上次修改的
                                   日期。
                        @ftime   - 傳回檔案上次修改
                                   的時間。

                        要在命令列中包含特殊字元的話,
                        請使用 0xHH 格式的十六
                        進位字元碼 (例如 0x09 代表 tab)。
                        內部的 CMD.exe 命令應該
                        以 "cmd /c" 執行。

    /D    date          選取檔案上次修改的時間大於或
                        等於 (+) 、小於或等於 (-),
                        使用 "yyyy/MM/dd" 格式指定的日期;
                        或選取檔案上次修改
                        的時間大於或等於 (+)
                        目前的日期再加上 "dd" 天、
                        小於或等於 (-) 目前的日期減去 "dd" 天。
                        有效的 "dd" 可以是介於
                        0 - 32768 之間的數字。
                        如果未指定,"+" 將被視為預設符號。

    /?                  顯示這個說明訊息。

範例:
    FORFILES /?
    FORFILES 
    FORFILES /P C:\WINDOWS /S /M DNS*.*
    FORFILES /S /M *.txt /C "cmd /c type @file | more"
    FORFILES /P C:\ /S /M *.bat
    FORFILES /D -30 /M *.exe
             /C "cmd /c echo @path 0x09 was changed 30 days ago"
    FORFILES /D 2001/01/01
             /C "cmd /c echo @fname is new since Jan 1st 2001"
    FORFILES /D +2011/3/10 /C "cmd /c echo @fname is new today"
    FORFILES /M *.exe /D +1
    FORFILES /S /M *.doc /C "cmd /c echo @fsize"
    FORFILES /M *.txt /C "cmd /c if @isdir==FALSE notepad.exe @file"

在 Windows Server 2008 設定單一帳戶關閉多重遠端登入的方法

  1. gpedit.msc
  2. 電腦設定 / 系統管理範本 / Windows 元件 / 終端機服務 / 終端機伺服器 / 連線
  3. 限制終端機服務的使用者只能使用一個遠端工作階段 => 已啟用

The Will Will Web | 在 Windows Server 2008 設定單一帳戶多重遠端登入的方法

AutoPagerize DOM Event

window.addEventListener("AutoPagerize_DOMNodeInserted",function(){alert('Hi');},false);
AutoPagerize for Greasemonkey
相關文章:
M01 Auto Page Fix Img
Atuo TongWen

Atuo TongWen

4shared.com skip

// ==UserScript==
// @name           4shared
// @description    自動抓取下載連結
// @include        http://www.4shared.com/get/*
// @include        http://www.4shared.com/audio/*
// @include        http://www.4shared.com/file/*
// ==/UserScript==
if (document.getElementsByClassName('dbtn')[0]) location.assign(document.getElementsByClassName('dbtn')[0].href);
if (document.querySelector('#divDLStart a')) prompt('Download Link:',document.querySelector('#divDLStart a').href);

啟用快速啟動工具列 (Quick Launch)

%UserProfile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch\User Pinned\TaskBar
%appdata%\Microsoft\Internet Explorer\Quick Launch
%userprofile%\AppData\Roaming\Microsoft\Internet Explorer\Quick Launch
P.S.只有第一組支援內建快速鍵
Note:
%appdata% = %userprofile%\AppData\Roaming
Windows 7密技: 啟用Windows 7的快速啟動工具列 | 電腦網路 | 阿維雜記本 (Wei's Blog)

.net connector 6.3.4. failed to install

This is because you have to install .Net Framework 4.0 on your machine.
Install .Net 4 before install Connector/Net 6.3.4.0

MySQL :: Re: .net connector 6.3.4. failed to install on Win7 32bit

Firefox Profile 相關設定

profile.ini所在位置
%appdata%\Mozilla\Firefox\profiles.ini
不同profile,同時執行,捷徑參數
-no-remote -P <profile名稱>
如何讓 Firefox 有不同的設定檔,並讓它們能同時執行,實現帳號多開、區隔不同用途的瀏覽環境? | 0與1的邂逅