The My Opera forums have been replaced with forums.opera.com. Please head over there to discuss Opera's products and features

See the new Forums

UserJS newbie, need help (plus a question about Opera)

Forums » General Opera topics » User JavaScript

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

20. November 2011, 18:55:59

D1sasterp1ece

Behind the Mirror

Posts: 1178

UserJS newbie, need help (plus a question about Opera)

So I recently began playing around with User JavaScript, I'm writing simple scripts for like changing some part of the the page's title, getting a portion of a cookie and so on. I use Notepad++ for writing and Opera 11.60 (1159), 12.00 (1155) for actually running the scripts.

What I found (may even be a bug in both versions): setting UserJS folder only for one site works as expected and the script runs fine, but changing the script on the fly may prevent it from working - if I make a syntax error or something, the Error Console will alert me about it the first time, but nothing afterwards. Using Dragonfly, I found that even if I correct the errors, the .js file would not be reloaded, like Opera sees the errors and ignores the file (contrary to the statement that "Opera does not need to be restarted to see any changes to User JavaScript files."). The script may load again if I rename it, but this makes things slow - I want to write something more complex for my own needs, but this probable bug impairs me.
I tried ticking "Always load User Javascript" in opera:config, but this does not work. Is there any other setting I may not be aware of, or this may be considered a bug?

Anyway, thanks for your time for at least reading this (cause my way of expressing is a mess), I'd gladly appreciate any help on this question.
А crappy old PC running XP Pro SP3 and Opera 11.64 (1403) + 12.02 (1578) + 12.16 (1860) (plus a few other builds)
Loyal Opera user saying NO to Opera 15.
Opera Mobile 16 & Opera Mobile 16 beta & Opera Mobile 12.1 & Opera Mini 7.5 on Samsung Galaxy Nexus
Opera Mobile 12 & Opera Mini 7 on Nokia E51

20. November 2011, 20:14:08

Frenzie

Posts: 15571

You could use the general UserJS folder while you're developing it and only move it into a site-specific one when you're done?
The DnD Sanctuary — a safety net for My Opera's demise.

20. November 2011, 21:16:12

D1sasterp1ece

Behind the Mirror

Posts: 1178

It seems to be all the same even if I place the file in the globally set User JavaScript folder - the only way to make a script work after intentionally making a syntax error and then correcting it is to give the file a new name, and a name of a script that's been "erroneous" at some point won't work. That being said, I noticed that Opera kind of "blacklists" filenames for the current session - I can't just switch between two names for the sake of fooling Opera, I must either choose a name that hasn't been used before or one that has been used, but has also been working.

By the way, setting the UserJS folder globally should also set it to sites without previously saved Site Preferences, right?
А crappy old PC running XP Pro SP3 and Opera 11.64 (1403) + 12.02 (1578) + 12.16 (1860) (plus a few other builds)
Loyal Opera user saying NO to Opera 15.
Opera Mobile 16 & Opera Mobile 16 beta & Opera Mobile 12.1 & Opera Mini 7.5 on Samsung Galaxy Nexus
Opera Mobile 12 & Opera Mini 7 on Nokia E51

21. November 2011, 12:28:09

D1sasterp1ece

Behind the Mirror

Posts: 1178

Just tried the same thing in an old version I happen to keep - Opera 11.50 (1052) - and everything is okay - intentionally introducing an error in a script and then correcting it makes the script work again without changing its name. So do I consider this a bug? I think it's related to the different JS engine (Presto 2.09 vs. 2.10). So I'll care to test this in the latest final (11.52) and post about the issue in 11.60 and 12.00.
А crappy old PC running XP Pro SP3 and Opera 11.64 (1403) + 12.02 (1578) + 12.16 (1860) (plus a few other builds)
Loyal Opera user saying NO to Opera 15.
Opera Mobile 16 & Opera Mobile 16 beta & Opera Mobile 12.1 & Opera Mini 7.5 on Samsung Galaxy Nexus
Opera Mobile 12 & Opera Mini 7 on Nokia E51

21. November 2011, 16:32:39

Moderator

larskl

~ moderator ~

Posts: 22806

There’s no reason to use site-specific settings for UserJS. Thanks to the @include/@exclude lines in the header of the userjs you can control where the userjs runs far more fine-grained than you can do with site-specific settings. So just put them all in one global folder and be done.

21. November 2011, 17:29:11

D1sasterp1ece

Behind the Mirror

Posts: 1178

Originally posted by larskl:

There’s no reason to use site-specific settings for UserJS. Thanks to the @include/@exclude lines in the header of the userjs you can control where the userjs runs far more fine-grained than you can do with site-specific settings. So just put them all in one global folder and be done.



Excuse me, sir, but did you read my last two posts?
А crappy old PC running XP Pro SP3 and Opera 11.64 (1403) + 12.02 (1578) + 12.16 (1860) (plus a few other builds)
Loyal Opera user saying NO to Opera 15.
Opera Mobile 16 & Opera Mobile 16 beta & Opera Mobile 12.1 & Opera Mini 7.5 on Samsung Galaxy Nexus
Opera Mobile 12 & Opera Mini 7 on Nokia E51

21. November 2011, 19:12:30

Moderator

larskl

~ moderator ~

Posts: 22806

Yes. So? I didn't say "put them in a global folder and it'll work" but "put them in a global folder because site specific folders for userjs makes no sense"

22. November 2011, 19:25:55

D1sasterp1ece

Behind the Mirror

Posts: 1178

Originally posted by larskl:

Yes. So? I didn't say "put them in a global folder and it'll work" but "put them in a global folder because site specific folders for userjs makes no sense"



In which way is it wrong to only have a user script running for one site?
А crappy old PC running XP Pro SP3 and Opera 11.64 (1403) + 12.02 (1578) + 12.16 (1860) (plus a few other builds)
Loyal Opera user saying NO to Opera 15.
Opera Mobile 16 & Opera Mobile 16 beta & Opera Mobile 12.1 & Opera Mini 7.5 on Samsung Galaxy Nexus
Opera Mobile 12 & Opera Mini 7 on Nokia E51

30. November 2011, 01:16:14

spadija

Posts: 1643

It isn't wrong. If you use @include and @exclude rules, Opera will not run the script on every site—just the ones that are @included and not @excluded. Both methods for restricting a script to a certain site are equally valid, but I prefer @includes as you don't have to mess with site preferences.

I believe someone else already found the bug with Opera essentially blacklisting scripts with errors in 11.60+. I do not know if it has been reported or not.

30. November 2011, 09:32:40

Opera Software

hallvors

Opera Software

Posts: 1778

Originally posted by spadija:

I believe someone else already found the bug with Opera essentially blacklisting scripts with errors in 11.60+. I do not know if it has been reported or not.



It is reported and should get fixed in the not too distant future. The only workaround I know about is to either re-start Opera or use "Save as" and give the script a new name after fixing the syntax error - sorry about the nuisance :-/

--
My blog: miscoded
Stupid code from major websites uncovered and criticised
Contribute site fixes! - OTW&TA- all sites must work

30. November 2011, 21:59:28

D1sasterp1ece

Behind the Mirror

Posts: 1178

Originally posted by hallvors:

Originally posted by spadija:

I believe someone else already found the bug with Opera essentially blacklisting scripts with errors in 11.60+. I do not know if it has been reported or not.

The only workaround I know about is to either re-start Opera or use "Save as" and give the script a new name after fixing the syntax error [...]



Yup, that's what I've found out as well.
I'm staying with 11.52 for now, at least for writing and [de]bugging purposes - you know, making lots of errors is just part of the learning process, and as I stated, I'm a JS newb wanting to learn.
А crappy old PC running XP Pro SP3 and Opera 11.64 (1403) + 12.02 (1578) + 12.16 (1860) (plus a few other builds)
Loyal Opera user saying NO to Opera 15.
Opera Mobile 16 & Opera Mobile 16 beta & Opera Mobile 12.1 & Opera Mini 7.5 on Samsung Galaxy Nexus
Opera Mobile 12 & Opera Mini 7 on Nokia E51

Forums » General Opera topics » User JavaScript