Martin Kadlec blogging

UserJS - External scripts v1.1

I create extensions from this userJS, you can downlod it here:

https://addons.labs.opera.com/addons/extensions/details/external-scripts/1.0/?display=en

Comments
Please login to post comments.
Avatar
08.02.2013 15:02
OK, so I'll probably stay with the old version for the next time and wait for the update.
Avatar
08.02.2013 03:02

Originally posted by Big_Mike:

Is this already feature complete? Actually the white list in the old version was very handy.


It is not, I'm waiting for better URL API :)
Avatar
08.02.2013 00:02
Ah thank you :) Seems to work fine here, while the comment says "Opera 12.60+".
Is this already feature complete? Actually the white list in the old version was very handy.
Avatar
07.02.2013 23:02
Hi, I'm sorry to bug you, but I don't understand Opera's behavior. How is script blocking working?

I'm using Opera 12.14 without urlfilter.ini and no other "block" extensions but "External Scripts 1.21" (with the option to block external scripts enabled). I'm using Privoxy as a proxy server.

For example on the page www.winfuture.de:
External scripts tells me it blocks
http://adserver.freenet.de/js.ng/site=wf&affiliate=wf&adset=bsl&prod=wf_home&tbl=channel&ppos=9&wi=0&tie=free
http://adserver.freenet.de/js.ng/site=wf&affiliate=wf&ppos=14&wi=0&tie=free&band=256
http://pagead2.googlesyndication.com/pagead/show_ads.js
http://adserver.freenet.de/js.ng/site=wf&affiliate=wf&prod=wf_home&tbl=channel&ppos=16&wi=0&tie=free
http://adserver.freenet.de/js.ng/site=wf&affiliate=wf&adset=bsl&prod=wf_home&tbl=channel&ppos=11&wi=0&tie=free
http://adserver.freenet.de/js.ng/site=wf&affiliate=wf&adset=bsl&prod=wf_home&tbl=channel&ppos=1&wi=0&tie=free
http://adserver.freenet.de/praeludium/praeludium_winfut.js
http://j.wfcdn.de/j/jquery-1.6.2.min.js
http://j.wfcdn.de/j/clickheat,160510.js
http://j.wfcdn.de/j/winfuture,59.js

While Privoxy tells me, that Opera requests these scripts:
j.wfcdn.de/j/winfuture,59.js
j.wfcdn.de/j/clickheat,160510.js
j.wfcdn.de/j/jquery-1.6.2.min.js
http://adserver.freenet.de/praeludium/praeludium_winfut.js

If blocking is done by filtering the script files, why does Opera request some?
If blocking isn't done by this way - why doesn't Opera request all of the script files?
Avatar
07.02.2013 23:02
it is bug in Opera, sometimes the blocking script isn't fact enough so some scripts starts loading before the extension can block them. The only way to solve this problem is to use the new URL fitler API, I have an alpha version of it available on :

http://files.myopera.com/BS-Harou/files/external-scripts.oex

it works bit differently, but it still does the job
Avatar
13.09.2012 01:09

Originally posted by wpost:

Assuming this is doable, where would I find the configuration file on each box?


http://my.opera.com/wpost/blog/external-scripts?cid=96375322#comment96375322
Avatar
13.09.2012 00:09
Awesome extension! Many thanks for your great work.

I've been using it for a while on my Linux box home, and more recently put it on my Windows box at work. Rather than wasting time configuring each installation separately I'd like to use file synchronization to share their configuration file. That way if (for example) I add https://example.com/* to the whitelist at home, it automatically gets added to the whitelist at work.

Assuming this is doable, where would I find the configuration file on each box? Poking around on the Windows box I'm now on (the boss is out and I'm slacking off), External Scripts seems to use the directory %drive%UsersUSERAppDataLocalOperaOperawidgetswuid-6fd5eb00-3914-f94c-837c-80637c14044f, but even after examining the contents of that directory I'm still not sure what file(s) there should be synchronized. But once I figure out what to synchronize on one OS, the other should be easy.
Avatar
23.12.2010 23:12
so all these conflicts are because of opera.....
I think your one is the best because it's the only one that shows which scripts are blocked and which ones not (internal noads script blocking and content blocker helper don't do it)

even notscripts doesn't work with noads....but it's a bit different...more similar to the firefox extension.
Avatar
23.12.2010 19:12
Marco: I stoped developing this extension because of some bugs in Opera. Once they'll fix them I will create much beter version :)
Avatar
23.12.2010 18:12
sometimes this extension doesn't work and it would be nice if you could solve the conflict with Noads

external script is better for scripts but i need noads to hide elements.

thanks
Avatar
20.12.2010 10:12
the add-on doesn't work on www.sina.com.cn and www.ifeng.com
please fix it, thanx~

hmmm, that's strange... it works again but still refuses to show the dialog...

P.S. on www.taobao.com the dialog doesn't show as well
Avatar
17.12.2010 07:12
v1 in extension is better than version1.2.6 in userJS :)
Avatar
17.12.2010 04:12
hi,

your script is awesome. i notice there is version 1.2.6 of you external scripts, but in opera extension and in your blog title it says version 1.1, where can i get version 1.2.6, because your extension is great.
Avatar
10.11.2010 05:11
It seems to be an extension specific problem, because it works with the "normal" userJS+button combination, and they are basically the same.

Let's hope the options pages for extensions mentioned here comes soon, too :)
Avatar
09.11.2010 21:11
The error is not your fault. Opera itself seems to have timing problem with extensions that utilize script or local storage. The errors vary but all are concerning local or script storage. The object seems not to be initialized correctly sometimes...

I put in some

try { window.localStorage.getItem("userjs_extscripts_ad"); } catch(err) { alert(window.localStorage); alert(window.localStorage.getItem); }

and similar for the other items, but got no meaningful results which convinced me, that it is Operas fault indeed...
Reported as DSK-318457 and hoping they get it under control.
Avatar
09.11.2010 21:11
I found a way how to get rid off scriptStorage, but there are other bugs with this solution so I still have to wait for some fixes :P
Avatar
08.11.2010 07:11
Got a strange error in the console:

JavaScript
Unknown thread
Uncaught exception: TypeError: 'scriptStorage.getItem' is not a function
Error thrown at line 25, column 4 in <anonymous function>(scriptStorage):
var
called from line 24, column 2 in program code:
window.opera.userjs.extscripts.show = (function(scriptStorage){



BTW: Did you ever try to use an (any) extension in a private tab? AFAICS they don't work there ...
Avatar
03.11.2010 11:11
Ok :)
Avatar
03.11.2010 10:11
Can you include the version number in the help(?) next time?
It is easier to check if it is visible in plain sight :)
Avatar
23.10.2010 09:10
My plan is to move dialog and a big part of the script to the extension. That should help with the collisipns. But firstly Imust find 100% working way to send a message only to focused tab.
Avatar
22.10.2010 22:10
:bug:
Unknown thread
Uncaught exception: TypeError: 'window.localStorage.getItem' is not a function
Error thrown at line 25, column 4 in <anonymous function>(scriptStorage):
var
called from line 24, column 2 in program code:
window.opera.userjs.extscripts.show = (function(scriptStorage){

but only at the page
http://www.greywyvern.com/code/javascript/keyboard

and only when no global block is set and if I reload the page. As soon as I activate "other domain" it works without throwing an error...
Avatar
22.10.2010 22:10

Originally posted by Lex1:

I hope it's just a bug Opera.


There indeed seems to be a bug in Opera. I can't nail it down but when I install the WOT script too, script execution becomes unpredictable. Scripts that utilize script storage and|or local storage don't seem to work good together...
Avatar
22.10.2010 11:10

when I have your extension installed then my extension stops working when I try to access script storage


I hope it's just a bug Opera.

Whitelisting

static.myopera.com/*
files.myopera.com/*
api.mywot.com/*
ajax.googleapis.com/ajax/*
...
etc.


Btw. Whitelist for scripts from noads:
^http://ajax.googleapis.com/|^http://www.google.com/jsapi|^http://maps.google.com/|^http://www.google.com/recaptcha/|^http://[0-9a-z-]+.gstatic.com/|^http://[0-9a-z-]+.appspot.com/|^http://yui.yahooapis.com/|^http://script.aculo.us/|^http://ipinfodb.com/|^http://api.recaptcha.net/|^http://rutube.ru/|^http://css.yandex.net/|^http://api-maps.yandex.ru/|^http://sd+.addthis.com/js/|^http://sd+.ucoz.net/src/u.js|^http://[0-9a-z-]+.imgsmail.ru/|^http://62.105.135.100/|^https?://auth.tbn.ru|^https://easylist-downloads.adblockplus.org/[a-z_+-]+.txt$|^https://secure.fanboy.co.nz/fanboy-adblock.txt$|swfobject.js$|show_afs_search.js$|chart.js$|ajax.js$|widgets.js$|common.js$|AC_RunActiveContent.js$|jquery[0-9a-z.-]*.js$
Avatar
22.10.2010 09:10
Hm.... Are script/extension DBs possible or does Opera not support that?
A database would be just fine to store huge amounts of data and could improve the speed, even if speed is no issue with your script.
Avatar
22.10.2010 08:10
The extension adds
userjs_extscripts_ad ["off","on"]
or any other "on","off" combination to the local storage of every webpage. If I clean the web storage out of various reason, this information will be lost. Block external and same domain seem to be global settings, so is it possible to move this information to the script storage?
Avatar
22.10.2010 08:10
Unfortunately not :( I have to test local vs script storage if there is a difference
Avatar
22.10.2010 07:10
Possible problem in the future:

A pre-configured white list for "safe" scripts could come handy for all users who hare not firm enough (there will be many because the add-ons page will be used heavily, that is another dimension than it was with the pure UserJS somewhere in some "hidden" blog ;)) to unblock the necessary files of some vital external scripts, especially if an external script calls further scripts like for example one of the big libraries like YUI can do.

Example:
The user visits a page. He sees, that the YUI is blocked, puts it on the whitelist and the page is still b0rked because he doesn't recognize, that the library calls a second script after it is unblocked. The called script will still be blocked - as long as the user doesn't open your extension a second time to see what else is needed to run the page properly.

Could help to avoid problems with future extensions like the WOT extension too (WOT will release one, at least they said so on their page) - they'll for sure call their API from within the extension.

Whitelisting

static.myopera.com/*
files.myopera.com/*
api.mywot.com/*
ajax.googleapis.com/ajax/*
...
etc.

in the source of the script could avoid that, may be with a setting:
[X] Use preconfigured white list

A hint about that in the help or a dedicated "how to" for a difficult page example (with screen shots) on a web page or a nice start up screen at first start would be fine, too:

"Block external", look what doesn't work on the website.
Open the extension again, look what new scripts are used and unblock the necessary scripts (some examples of scripts that belong to advertising and some that belong to JS libraries).
Reload the page and test if it works.
If not, open the extension again an check what new scripts have been called.
Allow the new scripts and repeat these steps until the page works as intended.
Avatar
22.10.2010 07:10
good idea, I put it on my to do list :)
Avatar
22.10.2010 07:10
Gee! You are fast with answering! Do you ever sleep? :lol:
I was still editing the comment because I forgot some things.
Avatar
22.10.2010 07:10
Also need a "White list" for sites...

- "Do not use extension on this site"
- "Do not block scripts from same domain on this site"
- "Do not block scripts from other domain on this site"


Avatar
21.10.2010 21:10

broadcastMessage(<DOMString> data, <array> ports)
This method is used to broadcast a data to all connected UserJS and popup environments associated with the extension.


My quick and dirty workaround:
*.js
	extension.onmessage = function(e){
if(window.top == window.self && e.data && window.decodeURI(e.data.slice(0, e.data.indexOf('|'))) == window.location.href.replace(window.location.hash, ''))switch(e.data.slice(e.data.indexOf('|';) + 1)){
case prefix + '_block_ads': run.blockEle(true); break;

}
};

index.html
opera.extension.broadcastMessage(window.encodeURI(opera.extension.tabs.getFocused().url)+ '|' +  e.data, 80)


Deleting the hash are need, because «opera.extension.tabs.getFocused().url» returned url without a hash.
Avatar
21.10.2010 21:10
Lex1: thank you very much for your help. Now I have to only find out why when I have your extension installed then my extension stops working when I try to access script storage
Avatar
21.10.2010 20:10

Originally posted by Lakitu7:

Lastly, how am I supposed to invoke the function to add a whitelist rule from the main tab?


Click (don't release the left mouse button), wait at least one second, and then release it :)
Avatar
21.10.2010 19:10

Originally posted by Lakitu7:

Is the button I would get from the extension exactly the same as the one from here or is there some danger to mixing this element from the userjs version with the extension version?



Both should work, but there were some "animation" troubles in last few snapshots of O10.70 with the old button.
Avatar
21.10.2010 19:10
Rightclicking the addressbar and hitting "reset toolbar to its defaults" made it show up. I got the idea from someone in the desktopteam announcement comments. So, now I'm all set.

Thanks for the help and the extension!
Avatar
21.10.2010 19:10

Originally posted by Lakitu7:

Thanks for the help and the extension!



You are weolcome. btw I "fixed" a bit the dialog issue, now the message only appears when you click on the button and don't have set the storage quota :). This fix will be in next version.
Avatar
21.10.2010 19:10
Another much more trivial bug report: whitelisted items may show as blocked in the script list

On facebook, I tested with all "other domain" blocked, and nothing works, since everything comes from fbcdn.net. I added a whitelist rule "fbcdn.net" and the site then worked: everything was whitelisted and the scripts ran, but the list of scripts in the extension still showed them all as blocked (red). Changing the whitelist rule to "http://*.fbcdn.net/*" makes them show up properly as whitelisted (blue)
Avatar
21.10.2010 19:10
it's not bug, there has to be the "*" character(s) :)
Avatar
21.10.2010 19:10
Yeah I realize that I should have used the wildcards, but not doing so produces a discrepancy between what actually happened (the scripts ran) and the status list (which said that the scripts did not run). That seems dangerous?

Lastly, how am I supposed to invoke the function to add a whitelist rule from the main tab? It seems to invoke if I click 3 times quickly. Is that right? It usually triggers various other opera menus / text highlighting to do so.
Avatar
21.10.2010 18:10

Originally posted by Lakitu7:

When I install the extension, the button doesn't show up anywhere. I have to manually add the button from this page. What toolbar is it supposed to show up on? I assumed it's added in something I have disabled but when I show all toolbars I can't find it.



Button should appear in addressbar. Do you use clean installation?

Originally posted by Lakitu7:

Also, upon first install I was spammed with dialog boxes upon every page load about needing to enable userjs storage quotas in opera:config. If there's a way, perhaps the extension should check for this or modify it.


Unfortunately, extension can't change any value in opera:config. The annoying dialog is there to force user to do one of those two thinks: 1) change the quote 2) uninstall extension. But I will probably change it to something less annoying :)
Avatar
21.10.2010 18:10

Originally posted by BS-Harou:

Button should appear in addressbar. Do you use clean installation?


No, I wanted to test an upgrade installation. I was surprised when the installer wanted to upgrade by default so I decided try it. I guess that's probably the cause but I don't know if there's anything you can do about it from your end or if it's part of the way Opera handles upgrade installs. Is the button I would get from the extension exactly the same as the one from here or is there some danger to mixing this element from the userjs version with the extension version?

Originally posted by BS-Harou:

Unfortunately, extension can't change any value in opera:config. The annoying dialog is there to force user to do one of those two thinks: 1) change the quote 2) uninstall extension. But I will probably change it to something less annoying


Oh okay, it's your popup. I thought it was something from the browser core, triggered by the extension. Maybe I just missed it in my excitement but if it doesn't already say something about the external scripts extension, it might make sense to do so.
Avatar
21.10.2010 18:10
Extension bug reports:

When I install the extension, the button doesn't show up anywhere. I have to manually add the button from this page. What toolbar is it supposed to show up on? I assumed it's added in something I have disabled but when I show all toolbars I can't find it.

Also, upon first install I was spammed with dialog boxes upon every page load about needing to enable userjs storage quotas in opera:config. If there's a way, perhaps the extension should check for this or modify it.
Avatar
21.10.2010 16:10

Originally posted by InDigazzZ:

Extension, running on the one page - opens on all others. When switching to another tabs have to close the extension's window.



Interesting, I still have a lot of things to learn from the extensions API. Anyway, I will try to fix it in next version.
Avatar
21.10.2010 15:10
Extension, running on the one page - opens on all others. When switching to another tabs have to close the extension's window.
Avatar
21.10.2010 15:10
Heh, you right:

broadcastMessage(<DOMString> data, <array> ports)
This method is used to broadcast a data to all connected UserJS and popup environments associated with the extension.

Avatar
21.10.2010 12:10
You can update your bug report about ease in/out for Opera 11 Alpha :awww:

BTW: The extension doesn't want to work at all even with a surgical clean Opera install.
It blocks the CSS hover effect on all links on my own page, it even blocks clicks on links - and I have exactly 0 (zero) JS on that page.
It even blocks loading of several pages completely :yikes:
I hope it is Opera's fault, not mine or yours
(I assume it is so, it has written Alpha all over the place :lol:)


The UserJS/button combination still works fine.

Edit: Scratch everything above apart from the Alpha thing!
I had to uninstall the UJS and the button, then it miraculously worked - and used the settings of extscripts.js despite the fact, that it was an "external device" install :confused:

Edit2: Did a second clean install (and many more for various reasons :D). The extension works fine, started from zero and the first thing I saw was the script storage warning - everything as it is supposed to be now :D

Wish, if possible with the extensions API: Option to set the script storage at first start of the extension if it is not already set.


Tested with XP SP3 - will test with W7 64Bit later.
Avatar
20.10.2010 16:10
Different specs, W3C vs. ECMA and this is a display thing, so IMHO the W3C CSS is the correct recipient :D
Avatar
20.10.2010 16:10
actually, this is not part of ECMA spec. DOM specification is doing w3c too. anyway, I don't care much how it will works, main thing is that it will be there)
Avatar
20.10.2010 15:10

Originally posted by QuHno:

theElement.inheritance = value;
or
theElement.setAttribute('inheritance',value);

If it is an attribute, you can script it



I know but I think that simple function has much more chances in spec than new css property.
Avatar
20.10.2010 12:10
theElement.inheritance = value;
or
theElement.setAttribute('inheritance',value);

If it is an attribute, you can script it :D

Show all comments