I'm trying to run a Tampermonkey script in Chrome on Facebook to customise my Facebook page.
I can run some simple script, but I can't load jQuery.
Refused to load the script 'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' because it violates the following Content Security Policy directive: "script-src 'unsafe-eval' https://.facebook.com http://.facebook.com https://.fbcdn.net http://.fbcdn.net *.facebook.net *.google-analytics.com *.virtualearth.net .google.com 127.0.0.1: .spotilocal.com: 'unsafe-inline' 'unsafe-eval' https://.akamaihd.net http://.akamaihd.net *.atlassolutions.com chrome-extension://lifbcibllhkdhoafpjfnlhfpfgnpldfl".
This is my code:
// Loads jQuery and calls a callback function when jQuery has finished loading
function addJQuery(callback) {
var script = document.createElement("script");
script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js");
script.addEventListener('load', function () {
var script = document.createElement("script");
script.textContent = "window.jQ1=jQuery.noConflict(true);(" + callback.toString() + ")();"; // jQ1 replaces $ to avoid conflicts.
document.body.appendChild(script);
}, false);
document.body.appendChild(script);
}
function main() {
// empty for now, but won't even run
}
addJQuery(main);
Is there a way for me to use jQuery?
I also tried pasting the source inline but got this error:
Uncaught ReferenceError: jQuery is not defined