Constantly updating cookie causes browser crash
PROBLEM BACKGROUND:
I usually leave my browser parked on my fantasy baseball live scoring page overnight. The next day, the browser is always sluggish and frequently crashes.
After some investigation, I'm convinced it's caused by a cookie being updated every 1 second by the site. If I have 5 tabs open on the sites' domain (which I frequently do), it updates the cookie 5 times per second.
DEBUGGING:
I use Firefox 4.0 with firebug and firecookie.
The session cookie is called "fsr.a" and contains a *nix timestamp. I believe it's called "foresee-trigger" and it's some kind of adware.
You can see it in action here (no need to log in): http://www.cbssports.com/
The cookie seems to be set by this file: http://sports.cbsimg.net/js/phase2-min-v0047.js
THE FIX:
I've tried Adblocking it, but that broke the site. I tried writing a Greasemonkey script to counter it, but I'm not good enough with JS yet. I obviously can't block all cookies on the domain.
Just looking for ideas or maybe a pointer in the right direction with a Greasemonkey script.
EDIT:
I wonder if I can just change the timer variable with Greasemonkey to update the cookie less frequently?
For reference, I believe this is the code responsible for the "fsr.a" cookie:
var FSR = {
version: "5.3.0",
date: "11/11/2009",
enabled: true,
files: "http://images.cbssports.com/script/foresee/",
id: "7alXWMyc064b1ROgR/DloA==",
sites: [{
path: /\w+-?\w+\.(com|org|edu|gov|net)/
}, {
p开发者_如何学运维ath: ".",
domain: "default"
}]
};
function fsr$setAlive() {
var a = new Date().getTime();
document.cookie = "fsr.a=" + a + ";path=/" + ((FSR.site.domain) ? ";domain=" + FSR.site.domain + ";" : ";")
}(function () {
if (window != window.top) {
return
}
function g(k) {
if (typeof k == "object") {
var l = k.constructor.toString().match(/array/i);
return (l != null)
}
return false
}
var e = FSR.sites;
for (var h = 0, a = e.length; h < a; h++) {
var c;
if (!g(e[h].path)) {
e[h].path = [e[h].path]
}
for (var j = 0, b = e[h].path.length; j < b; j++) {
if (c = document.location.href.match(e[h].path[j])) {
FSR.siteid = h;
FSR.site = FSR.sites[FSR.siteid];
if (!FSR.site.domain) {
FSR.site.domain = c[0]
} else {
if (FSR.site.domain == "default") {
FSR.site.domain = false
}
}
if (!FSR.site.name) {
FSR.site.name = c[0]
}
var d = ["files", "js_files", "image_files", "html_files"];
for (var h = 0, f = d.length; h < f; h++) {
if (FSR.site[d[h]]) {
FSR[d[h]] = FSR.site[d[h]]
}
}
break
}
}
if (c) {
break
}
}
if (!window["fsr$timer"]) {
fsr$setAlive();
window["fsr$timer"] = setInterval(fsr$setAlive, 1000)
}
})();
Alternate paste: http://pastebin.com/YrHFCZn1
It looks like you need to be registered and logged in for that site to set that cookie. I won't do that, so I can't test the fix.
BUT, looking at that JS, one or more of the following should work from Greasemonkey:
clearInterval (unsafeWindow["fsr$timer"]); unsafeWindow["fsr$timer"] = null;
unsafeWindow["fsr$setAlive"] = function () {}
Worse comes to worst:
- Copy that JS file to your PC.
- Edit it, to kill that timer.
- Use adblock to block just the original JS file.
- Use Greasemonkey to apply your modified JS.
精彩评论