The following script run successfully via the Chrome Web Console for months is suddenly not working.
// 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.");
}
The error thrown is:
Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '[object HTMLDocument]' is not a valid selector.
The offending line is:
$(document).ready()
Actions I took:
Command 1
$(document).ready(function($){ });
Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '[object HTMLDocument]' is not a valid selector.
Command 2
console.log($())
null
Command 3
$().jquery
Uncaught TypeError: Cannot read property 'jquery' of null(…)
Command 4
jQuery.jquery
Uncaught ReferenceError: jQuery is not defined(…)
Command 5
$('.class');
null
Tried to load jQuery by running the following code in the Web Browser:
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);
Got this error:
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.
Been combing the internet for a solution, but feel I'm in a deep rabbit hole. Is it that jquery's not loaded? Is it that the site I'm processing data from has added a new layer of security to thwart my automation?
I'm at a loss. Thanks in advance.
You posted the answer. 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
- jQuery is not loading properly. Try changing https://ajax
to just //ajax