或者可以使用環境變數
%USERPROFILE%
win 7 無法存取Application Data等資料夾
%USERPROFILE%
// ==UserScript==
// @name FDZ Article Link Clean
// @description FDZ Article Link Clean
// @include http://forum.fdzone.org/forumdisplay.php?fid=99*
// @include http://forum.*.fdzone.org/forumdisplay.php?fid=99*
// ==/UserScript==
var links=document.querySelectorAll('span[id^=thread] a');
for(var i=0;i<links.length;i++)
links[i].href=links[i].href.replace(/&i.*/i,'');
// ==UserScript==
// @name NPUST Net Flow Check
// @description NPUST Net Flow Check
// @include http://140.127.35.245/flowview/func/report/main_netflow_inout_theday_fast.php*
// ==/UserScript==
var osTop = new Array(); //記錄IP所在置位的offsetTop
var osTopSeq = 0; //預設顯示第幾筆位置,同時也用來記錄顯示至第幾筆位置
var trs = document.querySelectorAll('#maintable_netflow_inout > tbody > tr'); //表格內全部列
//切換位置
function movePos() {
osTopSeq++;
if (osTopSeq >= osTop.length) osTopSeq = 0;
window.scrollTo(0, osTop[osTopSeq]);
}
for (var i = 1; i < trs.length; i++) {
if (/140\.127\.22\.(228|234)/.test(trs[i].innerHTML)) {
//記錄ip所在offsetTop
osTop.push(trs[i].offsetTop);
//Highlight
for (var j = 0; j < trs[i].childNodes.length; j++)
if (trs[i].childNodes[j].nodeType == 1) trs[i].childNodes[j].style.backgroundColor = 'red';
}
}
//切換置預設位置
if (osTop.length != 0) window.scrollTo(0, osTop[0]);
//click表格可切換ip
document.getElementById('maintable_netflow_inout').addEventListener('click', movePos, false);
// ==UserScript==
// @name M01 Gallery Tradition View Redirect
// @description M01 Gallery Tradition View Redirect
// @include http://www.mobile01.com/gallerydetail.php*
// @include https://www.mobile01.com/gallerydetail.php*
// ==/UserScript==
/*var links = document.links;
for(var i = 0; i < links.length; i++) {
if (links[i].href.indexOf('topicdetail') != -1)
{
location.assign(links[i].href);
break;
}
}*/
location.assign(document.querySelector('a[href^="topicdetail.php"]').href);
// ==UserScript==
// @name M01 URL Redirect
// @description M01 URL Redirect
// @include http://www.play01.com/*
// @include http://www.shopping01.com/*
// @include http://5i01.com/*
// ==/UserScript==
location.assign(location.href.replace(/(5i01|www\.play01|www\.shopping01)/i,'www.mobile01'));
// ==UserScript==
// @name M01 Auto Load Img
// @description Auto Load M01 Img
// @include http://www.mobile01.com/topicdetail.php?f=*
// @include https://www.mobile01.com/topicdetail.php?f=*
// ==/UserScript==
unsafeWindow.LoadAttachImage();
window.addEventListener("AutoPagerize_DOMNodeInserted", function(){unsafeWindow.LoadAttachImage();}, false);
// ==UserScript==
// @name M01 Auto Page Fix Img
// @description AutoPage後,自動載入圖片
// @include https://www.mobile01.com/*
// @include http://www.mobile01.com/*
// ==/UserScript==
var i = 0;
function AP(event) {
var n = event.target;
if (n.tagName == 'DIV') {
if (i < document.getElementsByClassName('forum_content_main').length) {
unsafeWindow.LoadAttachImage();
i = document.getElementsByClassName('forum_content_main').length
}
}
}
window.addEventListener("DOMNodeInserted", AP, false);
// ==UserScript==
// @name M01 Auto Page Fix Img
// @description AutoPage後,自動載入圖片
// @include http://www.mobile01.com/topicdetail.php?f=*
// @include https://www.mobile01.com/topicdetail.php?f=*
// ==/UserScript==
window.addEventListener("AutoPagerize_DOMNodeInserted", function(){unsafeWindow.LoadAttachImage();}, false);
<style>
#RecentComments p { font-size:1em; }
#RecentComments a.s { font-size:0.8em; }
</style>
<script type="text/javascript">
function recentcomments(json) {
var d = document.getElementById('RecentComments');
var author, content, url;
for (var i = 0, l = json.feed.entry.length; i < l; i++) {
author = (json.feed.entry[i].author[0].name.$t == 'Anonymous') ? '你是誰' : json.feed.entry[i].author[0].name.$t;
url = json.feed.entry[i].link[2].href;
content = (json.feed.entry[i].title.$t.length > 14) ? json.feed.entry[i].title.$t.substring(0, 14) + '<a class="s" href="' + url + '">(略)</a>' : json.feed.entry[i].title.$t;
var r = document.createElement('p');
r.innerHTML = '<a href="' + url + '">' + author + '</a> 說: <br />' + content;
d.appendChild(r);
}
}
</script>
<div id="RecentComments"></div>
<script src="/feeds/comments/default?max-results=5&alt=json-in-script&callback=recentcomments"></script>
//方法1 (判斷nodeType等於TEXT_NODE)
var ca=document.getElementsByClassName('comment-author');
for(var i=0;i<ca.length;i++)
{
for(var j=0;j<ca[i].childNodes.length;j++)
if((ca[i].childNodes[j].nodeType ==3) && (ca[i].childNodes[j].nodeValue.indexOf('匿名') != -1))
ca[i].childNodes[j].nodeValue=ca[i].childNodes[j].nodeValue.replace('匿名','不知道是誰');
}
//方法2 (使用textContent屬性,IE不支援)
var ca=document.getElementsByClassName('comment-author');
for(var i=0;i<ca.length;i++)
if(ca[i].textContent.indexOf('匿名') != -1)
ca[i].textContent=ca[i].textContent.replace('匿名','不知道是誰');
var name = o && o.getName();
var name = otherName || "預設";
var allowed = (age > 18) ? "是" : "否";
for (var i = 0; i < a.length; i++) {
//處理 a[i]
}
for (var i = 0, len = a.length; i < len; i++) {
//處理 a[i]
}
var i = arr.length;
while (i--) {
a[i]
}
for (var i in a) {
//處理 a[i]
}
var KWs = ['1080', 'smg', 'MU', 'MEGAUPLOAD', 'MULTIUPLOAD', 'xuite', 'FB', 'FileBase', '多免空', 'JDOWNLOADER', '台版', '三區'];
function descStrLen(a, b) {
if (a.length < b.length) return 1;
}
KWs.sort(descStrLen);
control.AllowDrop = True; //記得一定要開,否則下面程式都不會跑
private void control_DragDrop(object sender, DragEventArgs e)
{
string[] filePaths = (string[])(e.Data.GetData(DataFormats.FileDrop));
foreach (string fileLoc in filePaths)
{
}
}
private void control_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effect = DragDropEffects.Link;
}
else
{
e.Effect = DragDropEffects.None;
}
}
x = "The answer is " + 50 //回傳值為 "The answer is 50"
y = 50 + " is the answer" //回傳值為 "50 is the answer"
"50" - 5 //回傳值為 45(將字串型態的值轉換為數值型態)
"50" + 5 //回傳值為 505(將數值型態的值轉換為字串型態)
"50" - 0 + 5 //回傳直為 55(數值字串遇到-0(減零)會先轉變成數值型態)
2010-10-04 基本架構完成
2010-10-05 使用GM API存取關鍵字
2010-10-06 使用GM_addStyle修正Inline stylesheet所引起的多次取代
2010-10-10 使用array.sort(compare function),自動排列關鍵字,字數較多者優先
2010-12-26 程式更名『FDZ Title Keyword Hightlight』
2011-03-05 文章描述加入搜尋
2011-03-09 加入開啟連結於新分頁和GUI
// ==UserScript==
// @name FDZ Title Keyword Hightlight
// @description 自動高亮文章標題關鍵字
// @author nightkid@FDZ
// @version 2011-03-09
// @include http://forum.fdzone.org/forumdisplay.php?fid=*
// @include http://forum.*.fdzone.org/forumdisplay.php?fid=*
// ==/UserScript==
GM_registerMenuCommand('FDZ Title Keyword Hightlight - Setting Keywords', settingKeywords);
GM_registerMenuCommand('FDZ Title Keyword Hightlight - Keywords List', listKeywords);
GM_registerMenuCommand('FDZ Title 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");}*/
//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'));
}
//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 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
//new tab state
var tar=GM_getValue('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);
var i, j, k, r, titleStr, descStr;
//先把KeyWord轉換成RegExp
var rKWs = new Array(); //RegExp KeyWords
for (k = 0; k < KWs.length; k++) {
r = new RegExp('(' + KWs[k] + ')', 'ig');
rKWs[k] = r;
}
for (i = 0; i < titles.length; i++) {
//取出文章標題超連結的文字
titleStr = titles[i].childNodes[0].innerHTML;
//比對關鍵字
for (j = 0; j < rKWs.length; j++) {
if (rKWs[j].test(titleStr)) titleStr = titleStr.replace(rKWs[j], '<span class=\"GM_gotit\">$1</span>');
}
titles[i].childNodes[0].innerHTML = titleStr;
titles[i].childNodes[0].target=(tar)?"_blank":"";
}
for (i = 0; i< descs.length; i++) {
//取出文章描述的文字
descStr = descs[i].innerHTML;
//比對關鍵字
for (j = 0; j < rKWs.length; j++) {
if (rKWs[j].test(descStr)) descStr = descStr.replace(rKWs[j], '<span class=\"gotit\">$1</span>');
}
descs[i].innerHTML = descStr;
}
}
main();
var Strs = ['aa', 'bb', 'cc', 'dd', 'ee'];
var rStrs = new Array(); //用來存放轉換完的RegExp
for (i = 0; i < Strs.length; i++) {
t = new RegExp('(' + Strs[i] + ')', 'i');
rStrs[i] = t;
}
javascript: (function () {
var img = document.querySelectorAll("div[id^=postmessage] img"),
tmp = '';
for (var i = 0; i < img.length; i++) {
if (img[i].src.indexOf(location.host) == -1) tmp += '<img onclick=\"this.src=this.src + \'?\'+new Date().getTime();\" style=\"border:1pt solid #000;margin:5px 0;padding:5px\" src=\"' + img[i].src + '\"><br>';
}
var n = window.open('', '').document;
n.open();
n.write(tmp);
n.close();
})()
img.src=img.src+'?'+new Date().getTime(); //強制重新載入圖片,略過cache
for (variable in object) {
code to be executed
}
// ==UserScript==
// @name FDZ ScrollTo Attach
// @description 開啟主題後,自動捲動至附件
// @include http://forum.*.fdzone.org/viewthread.php?tid=*
// @include http://forum.fdzone.org/viewthread.php?tid=*
// ==/UserScript==
function doit()
{
window.scrollTo(0,document.getElementsByClassName('t_attachlist')[0].offsetTop);
}
window.addEventListener ("DOMContentLoaded", doit, false);
window.addEventListener ("load", doSomething, false); //load事件的觸發要等網頁全部圖片、檔案下載完畢才會執行
window.addEventListener ("DOMContentLoaded", doSomething, false); //DOMContentLoaded事件的觸發不必等到圖片、檔案等下載完畢,就會執行
window.scrollTo(0,element.offsetTop); //垂直捲動網頁至element
<script>
function totalArticles(json) {
var tA = document.createElement('p');
tA.appendChild(document.createTextNode('文章總數 : ' + json.feed.openSearch$totalResults.$t));
document.getElementById('HTML1').appendChild(tA);
}
function totalComments(json) {
var tC = document.createElement('p');
tC.appendChild(document.createTextNode('回覆總數 : ' + json.feed.openSearch$totalResults.$t));
document.getElementById('HTML1').appendChild(tC);
}
</script>
<script src="/feeds/posts/default?alt=json-in-script&callback=totalArticles&&max-results=0" type="text/javascript"/></script>
<script src="/feeds/comments/default?alt=json-in-script&callback=totalComments&&max-results=0" type="text/javascript"/></script>
javascript: (function () {
function getInputText() {
var it = document.getElementsByTagName('input');
for (var i = 0; i < it.length; i++) {
if (it[i].type == 'text') {
var startPos = it[i].selectionStart;
var endPos = it[i].selectionEnd;
if (startPos == endPos) {
return 0;
}
return it[i].value.substring(startPos, endPos);
}
}
return 0;
}
function getTextarea() {
var ta = document.getElementsByTagName('textarea');
for (var j = 0; j < ta.length; j++) {
if (ta[j].selectionStart != ta[j].selectionEnd) return ta[j].value.substring(ta[j].selectionStart, ta[j].selectionEnd);
}
return 0;
}
var s = document.getSelection();
if (s.length == 0) s = getInputText();
if (s == 0) s = getTextarea();
if (s == 0) s = prompt('Enter a vocabulary.', '');
if (s.length != 0) window.open('http://www.google.com.tw/dictionary?aq=f&langpair=en|zh-TW&q=' + s + '&hl=zh-TW');
})()
#g:: ;定義按 Win + G 鍵,啟用 Google 字典
Clipboard = ;清空剪貼簿
Send, ^c ;送出 Ctrl + C
strlen:=StrLen(Clipboard) ;取得剪貼簿字串長度
if(strlen > 0)
{
ClipWait, 1 ;等待OS,剪貼簿等待1秒
Run , firefox.exe "http://www.google.com.tw/dictionary?aq=f&langpair=en|zh-TW&hl=zh-TW&q=%Clipboard%"
}
Return
#y:: ;定義按 Win + Y 鍵,啟用 Yahoo 字典
Clipboard = ;清空剪貼簿
Send, ^c ;送出 Ctrl + C
strlen:=StrLen(Clipboard) ;取得剪貼簿字串長度
if(strlen > 0)
{
ClipWait, 1 ;等待OS,剪貼簿等待1秒
Run , firefox.exe "http://tw.dictionary.yahoo.com/dictionary?p=%Clipboard%"
}
Return