I'm using a setTimeout that calls itself each time it runs to continual check the contents of different pages since each page gets loaded via ajax. It seems that the Facebook JS is running through all the possible setTimeout references and calling clearTimeout for each rendering my app useless.
Is there a way I can prevent my setTimeout from being squashed like a helpless little bug by Facebook's JS?
Here is my code so you can see what is going on and test your solution if you like:
ruleset a60x542 {
meta {
name "shun-the-facebook-likes"
description <<
shun-the-facebook-likes
>>
author "Mike Grace"
logging off
}
dispatch {
domain "facebook.com"
}
rule find_the_likes {
select when pageview "facebook\.com"
{
emit <|
KOBJ.a60x542.removeLikes = function() {
$K(".uiUfiLike, .like_link, .cmnt_like_link").remove();
var timeout = window.setTimeout(function() {
KOBJ.a60x542.removeLikes();
开发者_StackOverflow中文版 }, 4000);
console.log(timeout);
} // removeLikes()
KOBJ.a60x542.removeLikes();
|>;
}
}
}
Are you sure that FAcebooks is clearing your timeouts?
Is your console.log working?
You can use setInterval to comtinuely execute your function.
Try this, a solution which worked for me:
function fooBar(){
// your code goes here
console.log("see me every second");
setTimeout(fooBar, 1000);
}
setTimeout(fooBar, 1000);
精彩评论