我编写了一个脚本,将包含在图像源 URL 中的数字添加到页面。它工作得很好!
但是,我还希望它在具有 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 …Run Code Online (Sandbox Code Playgroud) 我正在研究Unicreatures的用户脚本,用于跟踪探索期间的事件.它工作(好吧,它工作,但仍然需要一些工作大声笑)但我需要一种方法来显示我正在收集的信息,不涉及每个步骤的弹出警报.
我想在这个页面的菜单左侧创建一个框架,窗口,并在我的脚本运行时将各种变量的值写入其中.
我正在localStorage中收集这些数据,所以我的脚本将首先更新各种localStorage属性,然后以某种方式在此框中显示结果:
localStorage.steps = Number(localStorage.steps) + 1;
displayValueInFloatingBox(localStorage.steps + ' in Sargasso' );
Run Code Online (Sandbox Code Playgroud)
我还想在此框中添加一个按钮来重置这些属性的值,这样我就可以选择永久保持跟踪,或者只选择一两个会话,而不必每次都编辑脚本(特别是如果我决定的话)分享剧本).我假设这只是将变量设置为零,所以我只需要知道如何创建按钮并使它做某事......这可能会以某种方式使用eventListener.
请坚持使用简单的JavaScript,没有jQuery ......我现在还没有获得JavaScript.请解释答案,这样我就能理解某些东西是如何工作的 - 我不仅仅希望代码片段让我回到类似的问题,因为我不明白为什么会使用一些代码.
// ==UserScript==
// @name Unicreatures Egg pop-up
// @namespace Unicreatures Egg pop-up
// @description Unicreatures Egg pop-up
// @include http://unicreatures.com/explore.php*
// @include http://www.unicreatures.com/explore.php*
// ==/UserScript==
var regexp = /You find an? (Exalted )?(.*?) egg nearby/;
var match = regexp.exec( document.body.innerHTML );
if ( match ) {
if ( match[1] ) {
alert( "Exalted egg found: " + …Run Code Online (Sandbox Code Playgroud)