I want to execute a tamper monkey script on facebook page which polls database periodically for data and performs some actions. I tried implementing polling with ajax and below is the code for it
(function poll() {
setTimeout(function() {
$.ajax({
url: "xyz",
headers: {
'Content-Type': 'application/json',
'x-apikey': apiKey,
'cache-control': 'no-cache'
},
type: "GET",
success: function(data) {
// check if null return (no results from API)
if (data == null) {
console.log('no data!');
} else {
console.log(data);
},
dataType: "json",
complete: poll,
timeout: 2000
});
}, 3000);
})();
But when i execute the script, I get the below error
Refused to connect to 'xyz' because it violates the following Content Security Policy directive: "connect-src *.facebook.com facebook.com *.fbcdn.net *.facebook.net .spotilocal.com: .akamaihd.net wss://.facebook.com:* https://fb.scanandcleanlocal.com:* .atlassolutions.com attachment.fbsbx.com ws://localhost: blob: *.cdninstagram.com 'self' chrome-extension://boadgeojelhgndaghljhdicfkmllpafd chrome-extension://dliochdbjfkdbacpmhlcpmleaejidimm".
I understand that the error is because of content security policy directive defined by facebook.
Is there any way by which i can implement polling ? I also checked grease monkey GM.xmlHttpRequest but I could not find out a way to implement polling apart from using ajax.
I would appreciate if someone could help