gpt4 book ai didi

使用 Chrome Web Console 时 jQuery 似乎未加载

转载 作者:行者123 更新时间:2023-12-01 04:02:21 24 4
gpt4 key购买 nike

以下脚本通过 Chrome Web 控制台成功运行了几个月,但突然无法运行。

// Override site's disabling of the console.log function
console.log = console.__proto__.log

// get the DOM ready to process
$(document).ready()
function doThisThing(){
window._waitWindow = setInterval(function(){

// start looking for items not 'ready to go'
items = $("div.Catalogitem-content");
$.each(items, function(index){

if($(items[index]).find(".Catalogitem-stager").text().includes("ready to go") || index < lastitemCount){
$(this).css("background-color", "#84f784");
} else {
$(this).css("background-color", "#ff7089");
$(this).find(".engage-cycle-btn").click();
}
});
window.scrollTo(0, document.body.scrollHeight);
}, 10000);
return window._waitWindow;
}

function stopit() {
clearInterval(window._waitWindow);
console.log("Just executed clearInterval.");
}

抛出的错误是:

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '[object HTMLDocument]' is not a valid selector.

有问题的行是:

$(document).ready()

我采取的行动:

  1. 我检查了 jQuery 是否已正确加载。以下命令的结果让我相信 jQuery 没有正确加载......也许我错了?
<小时/>

命令 1

$(document).ready(function($){ });

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '[object HTMLDocument]' is not a valid selector.

命令 2

console.log($())

null

命令 3

$().jquery

Uncaught TypeError: Cannot read property 'jquery' of null(…)

命令 4

jQuery.jquery

Uncaught ReferenceError: jQuery is not defined(…)

命令 5

$('.class');

null

<小时/>
  • 尝试通过在 Web 浏览器中运行以下代码来加载 jQuery:

    var jq = document.createElement('script');jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js ";document.getElementsByTagName('head')[0].appendChild(jq);

  • 出现此错误:

    VM711:3 Refused to load the script 'https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js' because it violates the following Content Security Policy directive: blah blah blah.

    一直在互联网上寻找解决方案,但感觉我陷入了深深的兔子洞中。是jquery没有加载吗?我正在处理数据的网站是否添加了新的安全层来阻止我的自动化?

    我迷茫了。提前致谢。

    最佳答案

    您发布了答案。 拒绝加载脚本“https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js”,因为它违反了以下内容安全策略 - jQuery 是无法正确加载。尝试将 https://ajax 更改为 //ajax

    关于使用 Chrome Web Console 时 jQuery 似乎未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38233736/

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