gpt4 book ai didi

Jquery 与 Tampermonkey

转载 作者:行者123 更新时间:2023-12-01 00:03:45 24 4
gpt4 key购买 nike

所以我的控制台给了我这条消息 -

    The page at https://en.wikibooks.org/wiki/Vehicle_Identification_Numbers_(VIN_codes)/GM/VIN_Codes ran insecure content from http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js.
jquerified: true
ERROR: Execution of script 'GMVinCodeScraper' failed! $ is not defined
ReferenceError: $ is not defined
at getGMCodes (eval at <anonymous> (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21))))
at Function.eval (eval at <anonymous> (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21))))
at N (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21)))
at l (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21)))
at chromeEmu.extension.onRequest.addListener.Z (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21)))
at W (eval at eventHandler (eval at <anonymous> (chrome-extension://dhdgffkkebhmkfjojejmpbldmpobfkfo/content.js:57:21)))

在我的用户脚本中,我正在运行一个自动在页面上包含 jquery 的函数,并且似乎 jquery 已加载,因为我可以看到一个带有 jquery url 作为 src 属性的脚本标记。

作为引用,该函数在这里 -

function jquerify(jquerified){
if(!(window.JQuery && window.Jquery.fn.jquery == '1')){
var s = document.createElement('script');
s.setAttribute('src','http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js');
s.setAttribute('type','text/javascript');
document.getElementsByTagName('head')[0].appendChild(s);
jquerified = true;
console.log("jquerified: " + jquerified);
return jquerified;
}
}
jquerify(false);

所以,不确定为什么 $ 不会被定义。知道为什么吗?

更新-

使用@require解决了这个问题。

最佳答案

您可以使用@require url 来解决这个问题

// @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js

关于Jquery 与 Tampermonkey,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11852109/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com