...

View Full Version : Block only certain JS functions in a file



VIPStephan
01-23-2010, 04:36 AM
This is more of a general question about blocking scripts in Firefox. Say there is that link on a website that actually brings me to the location it pretends to but when clicking it it also launches an annoying popup window (with regular window.open). Iíve spotted the responsible function in a JS file with several other functions that are useful or (unfortunately) required to use the page. Is there a way to block only that one function that is responsible for the popup with NoScript, AdBlockPlus, or Firebug, but not the entire JS file? Or is there any other application/add-on that is able to do this?

_Aerospace_Eng_
01-23-2010, 08:29 AM
You can use Greasemonkey. Its a firefox addon that allows you to write custom javascript to be ran on page load. Do you know how the popup function is called? Is it called using onclick within the links?

VIPStephan
01-23-2010, 01:17 PM
Yes, it’s a plain onclick event handler in the HTML that executes the function that invokes the popup.

_Aerospace_Eng_
01-23-2010, 09:29 PM
I have this greasemonkey script I created that can set each onclick for every link on the page. You can also set the include to work only the site you want it to work on

// ==UserScript==
// @name Fix Links
// @namespace
// @include http://www.somesite.com/*
// ==/UserScript==
//var newurl, oldurl;
function changeLinks()
{
var getLinks;
getLinks = document.getElementsByTagName('a');
for(i=0; i < getLinks.length; i++)
{
getLinks[i].setAttribute('onclick','your new onclick stuff here');
}
}
window.addEventListener("load",changeLinks,false);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum