NoScript blocking Scripting/GM scripts from sending events

Ask for help about NoScript, no registration needed to post
Morac
Junior Member
Posts: 36
Joined: Thu May 21, 2009 5:33 pm

NoScript blocking Scripting/GM scripts from sending events

Post by Morac »

I'm using Scriptish to check when certain responses occur when loading a web page and redirect to another web page. As I need to have the referrer field set, I do this by having a user script add a link to the page and then create and dispatch a MouseEvents to click on it. That used to work until recently, when now it does nothing unless I allow scripts on the web page page (it's not a known set of pages so that's not possible).

Is there a way to have NoScript not block "click" events initiated from Scriptish?

Here's the code in my user script:

Code: Select all

// since referrer is not set by setting href in Firefox 4 and up, we need to create a link and "click" it.
var location = document.location.href.toLowerCase();
var newLink = document.createElement('a');
newLink.setAttribute('onclick', 'document.location.href = "' + location + '"');
document.body.appendChild(newLink);
var evt = document.createEvent("MouseEvents");
evt.initUIEvent("click", false, false, window, 1);
newLink.dispatchEvent(evt);
As far as I can tell, everything works up till the last line. That line processes (i.e. doesn't generate an error and returns true), but nothing happens.
Mozilla/5.0 (Windows NT 5.1; rv:9.0a2) Gecko/20111028 Firefox/9.0a2
User avatar
Giorgio Maone
Site Admin
Posts: 9524
Joined: Wed Mar 18, 2009 11:22 pm
Location: Palermo - Italy
Contact:

Re: NoScript blocking Scripting/GM scripts from sending even

Post by Giorgio Maone »

  1. The script as it's written above creates an infinite reload loop (you just cause the same URL to be loaded as soon as the document loads).
  2. It works fine for me both in GreaseMonkey and in Scriptish ("run when document loads"), no matter if the source page is allowed or not.
  3. You can simplify it a lot by replacing the last 3 lines with just "newLink.click()".
Mozilla/5.0 (Windows NT 5.2; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1
Morac
Junior Member
Posts: 36
Joined: Thu May 21, 2009 5:33 pm

Re: NoScript blocking Scripting/GM scripts from sending even

Post by Morac »

  1. I actually didn't include the code that changes the location based on the current location. So my code actually doesn't go into an infinite loop.
  2. Odd, sometimes it works, sometimes it doesn't. It's like it gets "stuck". It's working now though.
  3. Thanks for the info about that. That's a lot simpler.
Mozilla/5.0 (Windows NT 5.1; rv:9.0a2) Gecko/20111028 Firefox/9.0a2
Post Reply