我編寫了一個腳本,將包含在圖像源URL中的數字添加到頁面中。它很棒!如何在選擇圖像後使用waitForKeyElements顯示信息?
但是,我也希望它運行在具有AJAX驅動選項卡的頁面上。
我試過玩waitForKeyElements
,但我不知道如何使它工作,我不明白jQuery。
當我使用#dolls
時,它將所有標籤的所有內容放在頁面上...當我使用div.dolls
時,它禁用加載玩偶的按鈕。
// ==UserScript==
// @name Dex# of Pokedolls
// @namespace http://trueidiocy.us
// @include http://www.thepikaclub.co.uk/adopt/dolls.php?action=collection
// @include http://www.thepikaclub.co.uk/adopt/dolls.php?action=giveaway
// @include http://www.thepikaclub.co.uk/adopt/dolls.php?action=regional
// @include http://www.thepikaclub.co.uk/adopt/dolls.php?action=shop
// @include http://www.thepikaclub.co.uk/adopt/dolls.php?action=local&market=sell*
// @include http://www.thepikaclub.co.uk/adopt/dolls.php?action=local&market=buy*
// @include http://www.thepikaclub.co.uk/adopt/trainercard.php?trainer=*
// @version 1
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @grant none
// ==/UserScript==
waitForKeyElements (
"div.dolls" //also tried #dolls
, showdexno
);
function showdexno (jNode) {
var imgs = document.getElementsByTagName('img');
for (var i = imgs.length - 1; i >= 0; i--) {
if (imgs[i].src.indexOf('overworld') > -1) {
var textNode = document.createElement('b');
var numtext=imgs[i].src.match(/\d+/g)
textNode.innerHTML = numtext;
imgs[i].parentNode.appendChild(textNode, imgs[i]);
}
}
}
我可能只是沒有使用正確的語法什麼的,但我完全失去了。
我在this page測試腳本,它需要觸發時負載Pokédolls按鈕被點擊的Pokédolls標籤。
您可以查看該目標頁面而無需登錄。
我假設後,我得到這個工作,我只想拋開一切到一個if語句:
If location is trainer card wait for tab
else just run the code
那麼,我究竟做錯了什麼?如何爲此使用waitForKeyElements
?還是有另一種方式?
ETA:還有一個問題...在一個頁面上顯示的圖片旁邊的數字是完美的 - 但是 - 在其他頁面上的圖像下面有文本,它會將其添加到現有文本中。每次我如何使它在圖片旁邊?
我瘋玩在我上面的代碼......在我的腳本get_span_content是showdexno ......但我已經刪除了它,因爲它沒」 t工作,所以忘了改變後在我從例如複製我現在修復...現在是啊,我認爲2 jquerys可能會導致probs,但無法找到我讀到的有關它 –
Greasemonkey自動補充線......我最近剛剛上線從.92開始(我認爲......反正是9),並且認爲我會放棄這一行......所有我的舊腳本沒有它就能正常工作。 –
工作很不錯...但是我需要所有的娃娃圖像來顯示數字......臭味交易系統需要你輸入你想交易的娃娃的dex#,如果你不玩小精靈,你有不知道這些洋娃娃是什麼......它會看起來像「」#dolls td> img [src * ='overworld']「' –