Default include rule of "@include *" is a horrible, horrible idea.

46 views
Skip to first unread message

cantchooset...@hotmail.com

unread,
Oct 31, 2016, 1:38:51 AM10/31/16
to greasemonkey-users
OK, I guess that's subjective, but you can't blame me for trying to get your attention....

Anyway here is why I personally think it is a horrible idea.
I have been having really awful Firefox performance for months.  I figured it was just Firefox getting bloated and slow, or perhaps time to reinstall/upgrade my PC.  Tabs would take ages to close, and sometimes FF would just exit.  The main offenders are eBay and a few news sites I use often.  Yesterday for the first time in ages I went to the Tools->Greasemonkey menu, and happened to notice that a long-forgotten experimental user script I'd made for a news site (was running on the site I was on which was youtube.com.  I opened the script for editing, and saw this:

 // ==UserScript==
 // @name        Stop SMH video playing
 // @namespace   mystuff
 // @include     http://*.smh.com.au/*
 // @version     1
 // @grant       none
 // ==/UserScript==

 [ code here ]


So why is this running on youtube.com?  See if you can spot the problem before reading on...

Checking other tabs, I saw it was loaded in all the other tabs I had open too.  I checked the options, script settings, and included pages is listed as "*".  WTF??  I stared at the code for ages, making small tweaks to the metadata block but could not fix it, it was driving me nuts.  Finally I spotted it.  It's not obvious in most text editors, but the entire script was indented by one space.  That was enough to make GM ignore the entire metadata block, and default to "@include *".  It must have happened accidentally at some point after I took out all the alert() calls used for debugging, and shortly before I forgot about this project.

Putting an alert() back in, I saw that the script loaded dozens of times on each eBay tab, and dozens of times on news sites too, due to all the third party iframes and ad networks they use.  The script is also kind of resource heavy, reinvoking itself every couple of seconds by design.  Having fixed the problem, Firefox suddenly seems like lightning.

So this is my plea: is it reasonable for GM to warn if s script has a malformed metadata block, or no metadata block?  If not, could it at the very least, default to include none, as that is a much less damaging failure mode than including a script on every single page (and in every single frame/iframe in every single page) and will prompt the user to work out what is wrong immediately when the script does nothing, rather than appearing to work when it is actually degrading performance across all sites.

Thanks.
Reply all
Reply to author
Forward
0 new messages