Code: Select all
function patch(o, m, f) {
var saved = o[m];
f._restore = function() { o[m] = saved };
f._bypass = saved;
o[m] = f;
}
patch(w, "open", function() {
return patchAll(w.open._bypass.apply(w, arguments));
});
open(,'_self') does not return a new window so it gets double patched and w.open._bypass ends up with the patched open.
Code: Select all
_patch: (function() {
(function patchAll(w) {
if (!w || w.open._restore) return w;
var d = w.document;
function op(data) {
var code = "Object.getPrototypeOf(document)." +
(typeof(data) === "string"
? 'write.call(document, ' + JSON.stringify(data) + ')'
: 'open.call(document)'
);
var s = d.createElement("script");
s.appendChild(d.createTextNode(code));
var p = d.documentElement;
p.appendChild(s);
p.removeChild(s);
if (d.write === Object.getPrototypeOf(d).write) {
patchAll(w);
}
}
function patch(o, m, f) {
var saved = o[m];
f._restore = function() { o[m] = saved };
o[m] = f;
}
patch(d, "open", function() { op(null) });
patch(d, "write", function(s) {
op(typeof(s) === "string" ? s : "" + s);
});
patch(d, "writeln", function(s) { this.write(s + "\n") });
patch(w, "open", function() {
return patchAll(Object.getPrototypeOf(w).open.apply(w, arguments));
});
return w;
})(window);
}).toSource() + "()",
What prompted the introduction of _bypass in .29?