【发布时间】:2020-03-04 01:24:17
【问题描述】:
我正在尝试在 TamperMonkey 上使用 jQuery,所以我像这样在头部添加了所需的
// ==UserScript==
// @name Sliver.tv Bot
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Sliver.tv betting bot
// @author Pachi
// @include https://www.sliver.tv/win/fortnite
// @include https://www.sliver.tv/win/pubg
// @include https://www.sliver.tv/win/csgo
// @match https://www.sliver.tv/win/fortnite
// @match https://www.sliver.tv/win/pubg
// @match https://www.sliver.tv/win/cs
// @match https://www.sliver.tv/win/*
// @match https://www.sliver.tv/win*
// @grant none
// @require http://code.jquery.com/jquery-3.3.1.min.js
// ==/UserScript==
$(".waw-prediction-card").each(function (index) {
var SeleccionDeCarta = $(".waw-prediction-card").eq(index);
var SeleccionDeOpciones = $(SeleccionDeCarta).find(".waw-prediction-choice--active");
var CantidadDeOpciones = SeleccionDeOpciones.length;
var Random = Math.floor(Math.random() * CantidadDeOpciones);
var SeleccionFinal = $(SeleccionDeOpciones).eq(Random);
SeleccionFinal[0].click();
});
但我的脚本不工作。我在 "$" 旁边有一个黄色三角形,表示 $ 未定义,也许要求不起作用?
【问题讨论】:
-
我不确定你的意思,我用完整的脚本编辑了
-
我重新创建了脚本,首先添加了要求,保存,然后脚本并保存,sasme 错误;(
-
出于好奇,您是否尝试过在您的脚本中访问
window.$,而不是仅仅访问$以查看它是否有效?相关:stackoverflow.com/questions/51090754/… -
我试过了,错误消失了,但是脚本还没有工作,但是如果我在 chrome 的控制台上执行可以工作
-
删除
@grant none并且永远不要使用它,除非您真的需要在沙盒之外运行代码。
标签: javascript jquery google-chrome-extension