I'm trying to find 'banned words' on page and if they're found hide them and all images on a page. Hiding images works fine with this.$ = this.jQuery = jQuery.noConflict(true);
, but I have a problem with hide words. I use this code to do that:
txt = txt.replace(new RegExp(bannedWords[index], 'gi'),
'<span style=\'color:#000;background-color:#000\' class=\'banned\'>$&</span>');
there txt
is body's html. It works, but also emits conflicts with page's jQuery, because I use $('body').html(txt);
in the end.
To repeat my problem, use script
// ==UserScript==
// @name Words Filter
// @description Filter words and disable images if it founded
// @include http://myanimelist.net/*
// @version 3
// @require http://code.jquery.com/jquery-latest.min.js
// @grant none
// ==/UserScript==
//window.addEventListener('load', function ()
document.addEventListener('DOMContentLoaded',
function ()
{
// Monkey jQuery conflict solving
this.$ = this.jQuery = jQuery.noConflict(true);
//var $ = jQuery.noConflict(true);
//$('img').each(function(){$(this).hide();});
var txt = $("body").html();
$("body").html(txt);
console.log('works'); // it doesn't show anything in the console. Why?
});
on MyAnimeList page. On the top of page you can see menu bar with "Profile|Anime|Manga|Community|Industry". It has drop-down list, which isn't appeared with my script. Also, for some reason, console.log('works');
show nothing in the console.