Making a surrogate

General discussion about the NoScript extension for Firefox
Post Reply
access2godzilla
Senior Member
Posts: 109
Joined: Sun May 20, 2012 5:09 pm

Making a surrogate

Post by access2godzilla »

Say, I want to make a surrogate script which replaces scripts from a certain website.

If my surrogate is like:

Code: Select all

function foo () {
    /* do something */
}
Does foo() have a global scope? Can other code on the page call foo()?

Also, is it possible to make surrogates of entire frameworks (jquery, mootols etc.) in this manner?
Mozilla/5.0 (Windows NT 6.1; rv:21.0) Gecko/20130401 Firefox/21.0
barbaz
Senior Member
Posts: 11066
Joined: Sat Aug 03, 2013 5:45 pm

Re: Making a surrogate

Post by barbaz »

access2godzilla wrote:Can other code on the page call foo()?
A quick test with a local server indicates that yes, this is possible. Which makes me think that it should be possible to make surrogates for entire frameworks, but I haven't tried...
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:26.0) Gecko/20100101 Firefox/26.0 SeaMonkey/2.23
User avatar
Thrawn
Master Bug Buster
Posts: 3106
Joined: Mon Jan 16, 2012 3:46 am
Location: Australia
Contact:

Re: Making a surrogate

Post by Thrawn »

I suppose in theory you could get a copy of a specific version of eg JQuery, review it to ensure it's safe, and put it in as a surrogate whenever a site wants JQuery. I'm not sure what that would do performance-wise, though. I guess, if you use a file: URL, it could actually be faster.
======
Thrawn
------------
Religion is not the opium of the masses. Daily life is the opium of the masses.

True religion, which dares to acknowledge death and challenge the way we live, is an attempt to wake up.
Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:26.0) Gecko/20100101 Firefox/26.0
barbaz
Senior Member
Posts: 11066
Joined: Sat Aug 03, 2013 5:45 pm

Re: Making a surrogate

Post by barbaz »

Thrawn wrote:I guess, if you use a file: URL
@Thrawn, that feature doesn't work...
*Always* check the changelogs BEFORE updating that important software!
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:26.0) Gecko/20100101 Firefox/26.0 SeaMonkey/2.23
Post Reply