移動.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)