提问人:Jeff 提问时间:4/20/2011 最后编辑:Jeff 更新时间:4/21/2011 访问量:1439
不断更新 cookie 会导致浏览器崩溃
Constantly updating cookie causes browser crash
问:
问题背景:
我通常会将浏览器停在我的梦幻棒球实时得分页面上过夜。第二天,浏览器总是很慢,经常崩溃。
经过一番调查,我确信这是由网站每 1 秒更新一次 cookie 引起的。如果我在网站的域上打开了 5 个选项卡(我经常这样做),它会每秒更新 cookie 5 次。
调试:
我使用带有 firebug 和 firecookie 的 Firefox 4.0。
会话 cookie 称为“fsr.a”,包含一个 *nix 时间戳。我相信它被称为“预见触发器”,它是某种广告软件。
您可以在此处看到它的实际效果(无需登录): http://www.cbssports.com/
Cookie似乎是由以下文件设置的: http://sports.cbsimg.net/js/phase2-min-v0047.js
修复:
我试过Adblocking它,但这破坏了网站。我尝试编写一个 Greasemonkey 脚本来对抗它,但我对 JS 还不够好。我显然无法阻止域上的所有 cookie。
只是用 Greasemonkey 脚本寻找想法或指向正确方向的指针。
编辑:
我想知道我是否可以使用 Greasemonkey 更改计时器变量以降低更新 cookie 的频率?
作为参考,我相信这是负责“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)/
}, {
path: ".",
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)
}
})();
答:
看起来您需要注册并登录该站点才能设置该 cookie。我不会那样做,所以我无法测试修复程序。
但是,查看该 JS,以下一项或多项应该可以从 Greasemonkey 工作:
clearInterval (unsafeWindow["fsr$timer"]); unsafeWindow["fsr$timer"] = null;
unsafeWindow["fsr$setAlive"] = function () {}
更糟糕的情况是:
- 将该 JS 文件复制到您的 PC。
- 编辑它,以杀死该计时器。
- 使用 adblock 只阻止原始 JS 文件。
- 使用 Greasemonkey 应用修改后的 JS。
评论
clearInterval (unsafeWindow["fsr$timer"]);
评论