還參見"How to make Greasemonkey click lots of links one by one?"。
由於每個「刪除」按鈕,將打開一個新頁面,一個直接的點擊會從當前頁面導航。因此,請打開 s中的鏈接。
使用jQuery,使這一切更簡單,更可靠。這裏有完整的腳本 ...
對於一個簡單的靜態頁面:
// ==UserScript==
// @name _Fire lots of delete buttons
// @include http://YOUR_SERVER.COM/YOUR_PATH/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @grant GM_addStyle
// ==/UserScript==
var deleteLinks = $("a.delete");
deleteLinks.each (function() {
if (this.href) {
$("body").append (
'<iframe class="gmDelIfr" src="' + this.href + '"></iframe>'
);
}
});
//-- Use whatever CSS you desire. Like `display: none;`, for example.
GM_addStyle (" \
iframe.gmDelIfr { \
width: 80%; \
height: 2em; \
margin: 0; \
padding: 0; \
} \
");
對於AJAX驅動頁:(也適用於靜態頁)
// ==UserScript==
// @name _Fire lots of delete buttons
// @include http://YOUR_SERVER.COM/YOUR_PATH/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant GM_addStyle
// ==/UserScript==
waitForKeyElements ("a.delete", clickDeleteLink);
function clickDeleteLink (jNode) {
var thisHref = jNode[0].href;
if (thisHref) {
$("body").append (
'<iframe class="gmDelIfr" src="' + thisHref + '"></iframe>'
);
}
}
//-- Use whatever CSS you desire. Like `display: none;`, for example.
GM_addStyle (" \
iframe.gmDelIfr { \
width: 80%; \
height: 2em; \
margin: 0; \
padding: 0; \
} \
");
反向d近距離投票。這個問題將更接近於「如何使Greasemonkey單擊一個點擊大量鏈接?」](http://stackoverflow.com/q/10714395/331508),但它不完全相同。 –
Meta Discussion在http://meta.stackexchange.com/questions/183196/i-got-a-question-closed-by-mistake-please-help-me-reopen-it-if-you-agree。 –
@BrockAdams我真的在發佈之前找到了答案,但沒有找到任何答案。 – user2455524