扩展程序在我的网站上显示内容,我想使用JavaScript阻止它。有没有人知道如何阻止这些div类被创建?
答案 0 :(得分:0)
试用此代码:
function Init () {
var body = document.body;
if (body.addEventListener) {
body.addEventListener ('DOMNodeInsertedIntoDocument', OnNodeInsertedIntoDocument, false);
}
}
function OnNodeInsertedIntoDocument () {
var elements = ["mainPouchDiv", "pouchNotifyHeader", "nsPouchCrossPromotionContainer"];
var element = null;
var i = 0;
for (i = 0; i < elements.length; i++) {
element = document.getElementById(elements[i]);
if (element) {
document.body.removeChild(element);
element = null;
}
}
}