A more generalized replacement for NoScript's "surrogate scripts" functionality.
Posted on Sunday, January 25, 2009 at 11:18 PM.I saw an article today about the "surrogate scripts" functionality of the NoScript extension for Mozilla-based Web browsers. It essentially allows for a user to provide a replacement for a blocked script that some Web site requires to function properly.
I worked with a Web developer once who took a similar, although more general, approach to this problem. To avoid seeing ads and other unwanted content, he used his /etc/hosts file to resolve a number of such domain names to localhost. But some of the sites he visited often did make the mistake of having scripts that relied upon a function or variable defined in some of the scripts he had blocked. Some of the functionality of these sites was thus unavailable.
As a Web developer, he often switched back and forth between browsers, and often just used the last one he had open after testing work he had done for a client. So he wanted to avoid a browser-specific plugin. That's why he used his /etc/hosts file to block these sites in the first place.
His solution to this problem was to simply set up a Web server locally, and he manually created local JavaScript scripts that stubbed out the minimal functionality needed for the problematic Web sites to work. So regardless of the browser he was using, any requests for the blocked hosts were sent to his local Web server instad, and his minimal version of the script was served up instead. This resolved the problem with the missing functions or variables, prevented the Web sites' JavaScript code from crashing, and allowed him to use those sites.
I'd asked him if he ever ran into problems with two separate blocked hosts that both used the same JavaScript script filename, but the code itself was different. He said it wasn't something he'd ever encountered. If it ever did arise, he said he'd just include both script stubs in the same local file, and chances are there wouldn't be a conflict.








