Removing content loaded with JS?

112 views
Skip to first unread message

Hyoukou

unread,
Oct 2, 2007, 7:55:21 AM10/2/07
to greasemonkey-users
- How to remove content (elements) from a page that are loaded with a
javascipt?
- How to block a javascript from running if it has a function name xyz
e.g. getcommentinfo?

This is to remove the comments section from certain sites that contain
a lot of offensive spam and bypass my profanity filters because they
are loaded via javascript.

Example of content loaded via javascript:


<script language="javascript">
<!--
function getcommentinfo(userList,conList,timeList)
{

if (userList.length<=0 || conList.length<=0)
return ;
var str="";
for (i=0;i<userList.length;i++)
{
str += "<TABLE cellSpacing=0 cellPadding=0 border=0
class=comm_js><tr><td class=comm_js_title> Name: "+userList[i]+"
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Time:"+timeList[i]
+"</td></tr><tr><td class=comm_js_content><div> "+conList[i]+"</
div><br></td></tr></table>";
}
document.getElementById('commentinfoDiv').innerHTML = str;
}
document.getElementById('url').value = location.href;
//-->
</script>

Vectorspace

unread,
Oct 2, 2007, 10:42:49 AM10/2/07
to greasemon...@googlegroups.com
Greasemonkey cannot block on-page javascript - it is extecuted before
Greasemonkey is.

As for html content added by JavaScript, that should be possible if the
script is executed on page load
Just remove the offending elements as you would any other. The html code
for them would not be visible in view source because they are not in the
original document (only the script to add them is), but if you select
that part of the page and right-click > view selection source, you can
view the rendered html which will include those elements.

Hyoukou

unread,
Oct 8, 2007, 2:42:51 AM10/8/07
to greasemonkey-users
Your wrong - I managed to block on-page javascript with a greasemonkey
script generated with http://platypus.mozdev.org/index.html
Reply all
Reply to author
Forward
0 new messages