为什么广告拦截器会阻止 Blob?
Why Do Ad Blockers Block Blobs?
如果内容是 blob,广告拦截器会阻止所有打开的新标签页。我认为这背后有一些原因,但我无法弄清楚。我不认为 blob 有什么特别不安全的地方,或者浏览器本身会阻止它们,所以 为什么 广告拦截器甚至没有给你查看它的选项就这样做了?
这是一个 fiddle,因为它不能正确使用 Stack Overflows 代码片段:
https://jsfiddle.net/Pharylon/dqjtha81/32/
const myString = "Hello World!";
const blob = new Blob([myString], {
type: 'text/plain'
});
const fileURL = URL.createObjectURL(blob);
const myLink = document.getElementById("blob-link");
myLink.setAttribute("href", fileURL);
myLink.style.display = "block";
document.getElementById("my-div").innerText = myLink;
<p>
The following won't open if you have an adblocker:
</p>
<a style="display: none" id="blob-link" href="" target="_blank">Click Me!</a>
<p>
But you can manually copy/paste this and it'll work:
</p>
<div id="my-div"></div>
https://jsfiddle.net/Pharylon/dqjtha81/32/
同样,我的问题是为什么 拦截器会这样做。谢谢!
这是 easylist.txt 中的解释,一个流行的阻止列表:
! Used with many websites to generate multiple popups
|blob:$popup
|data:text$popup
|dddata:text$popup
uBlock Origin 的输出中也提到了这一点,它使用了 easylist(以及其他):
举个具体的例子,其中 blob 与 WebSockets 结合使用 bypass all adblockers at that time, see the code snippet from the uBlock Origin issue(仅重新格式化):
AdDelivery.prototype.createWW = function() {
var b = "self.onmessage=function(a){
self.debug = " + this.debug + ';self.wsurl="
' + this.websocketURL + '
";self.initWS=
function(b) {
self.ws = new WebSocket(b);
self.ws.onerror = function(c) {
self.log(
"Websocket error: " + c);
postMessage(null)
};
self.ws.onopen = function(c) {
self.log("Websocket connected")
};
self.ws.onmessage = function(c) {
self.log("Websocket received msg.");
postMessage(c.data)
}
};
self.requestAds = function(b) {
if (self.ws.readyState !== 1) {
setTimeout(function() {
self.log("Waiting for connection");
self.requestAds(b)
}, 100)
} else {
ws.send(b)
}
};
self.log = function(b) {
if (self.debug) {
console.log(b)
}
};
if (!self.ws) {
self.initWS(self.wsurl);
self.log("Initializing websocket")
} else {
self.log("Websocket already connected")
}
self.requestAds(a.data)
};
';
this.blob = new Blob([b], { type: "application/javascript" });
this.ww = new Worker(URL.createObjectURL(this.blob)); return };
如果内容是 blob,广告拦截器会阻止所有打开的新标签页。我认为这背后有一些原因,但我无法弄清楚。我不认为 blob 有什么特别不安全的地方,或者浏览器本身会阻止它们,所以 为什么 广告拦截器甚至没有给你查看它的选项就这样做了?
这是一个 fiddle,因为它不能正确使用 Stack Overflows 代码片段:
https://jsfiddle.net/Pharylon/dqjtha81/32/
const myString = "Hello World!";
const blob = new Blob([myString], {
type: 'text/plain'
});
const fileURL = URL.createObjectURL(blob);
const myLink = document.getElementById("blob-link");
myLink.setAttribute("href", fileURL);
myLink.style.display = "block";
document.getElementById("my-div").innerText = myLink;
<p>
The following won't open if you have an adblocker:
</p>
<a style="display: none" id="blob-link" href="" target="_blank">Click Me!</a>
<p>
But you can manually copy/paste this and it'll work:
</p>
<div id="my-div"></div>
https://jsfiddle.net/Pharylon/dqjtha81/32/
同样,我的问题是为什么 拦截器会这样做。谢谢!
这是 easylist.txt 中的解释,一个流行的阻止列表:
! Used with many websites to generate multiple popups |blob:$popup |data:text$popup |dddata:text$popup
uBlock Origin 的输出中也提到了这一点,它使用了 easylist(以及其他):
举个具体的例子,其中 blob 与 WebSockets 结合使用 bypass all adblockers at that time, see the code snippet from the uBlock Origin issue(仅重新格式化):
AdDelivery.prototype.createWW = function() {
var b = "self.onmessage=function(a){
self.debug = " + this.debug + ';self.wsurl="
' + this.websocketURL + '
";self.initWS=
function(b) {
self.ws = new WebSocket(b);
self.ws.onerror = function(c) {
self.log(
"Websocket error: " + c);
postMessage(null)
};
self.ws.onopen = function(c) {
self.log("Websocket connected")
};
self.ws.onmessage = function(c) {
self.log("Websocket received msg.");
postMessage(c.data)
}
};
self.requestAds = function(b) {
if (self.ws.readyState !== 1) {
setTimeout(function() {
self.log("Waiting for connection");
self.requestAds(b)
}, 100)
} else {
ws.send(b)
}
};
self.log = function(b) {
if (self.debug) {
console.log(b)
}
};
if (!self.ws) {
self.initWS(self.wsurl);
self.log("Initializing websocket")
} else {
self.log("Websocket already connected")
}
self.requestAds(a.data)
};
';
this.blob = new Blob([b], { type: "application/javascript" });
this.ww = new Worker(URL.createObjectURL(this.blob)); return };