(function() {
'use strict';
var blackWords = ['女朋友', '男朋友', '男生', '女生', '爱情', '重男轻女'];
function CheckIfContainBlackWords(title){
var res = false;
for(var i=0;i<blackWords.length;i++)
{
var strelements = blackWords[i];
if(title.match(strelements) != null){
res = true;
break;
}
}
return res;
}
//debugger;
// Get all elements
function DoBlock(){
var hotItems = document.getElementsByClassName("Topstory-recommend")[0].childNodes[0];
var length = 100;
for(var i = 0;i<length;i++){
if(hotItems == null){
hotItems = document.getElementsByClassName("Topstory-recommend")[0].childNodes[0];
}
var elements = hotItems.childNodes[i];
if( CheckIfContainBlackWords(elements.childNodes[0].childNodes[0].childNodes[0].textContent) == true){
console.info('remove node :'+ elements);
elements.remove();
i--;
length--;
}
}
}
var observer = new MutationObserver(function redelete(){
console.info('Webpage changed! Re-search nodes and delete.');
DoBlock();
});
observer.observe(document.body, {attributes:true,childList: true, subtree: true});
// Your code here...
})();