Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,695
    Thanks
    6
    Thanked 1,011 Times in 984 Posts

    Block only certain JS functions in a file

    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?

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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?
    Last edited by _Aerospace_Eng_; 01-23-2010 at 07:35 AM.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,695
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    Yes, it’s a plain onclick event handler in the HTML that executes the function that invokes the popup.

  • #4
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    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
    Code:
    // ==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);
    ||||If you are getting paid to do a job, don't ask for help on it!||||


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •