I've been looking through Google and www.userscripts.org for a script that lets you sort your user-scripts alphabetically, but I can't find any script that lets you do that [under the 'Manage User Scripts' page].
could anyone help me with this please?
thanks in advance
sort greasemonkey user-scripts alphabetically
- GarethB
- Posts: 118
- Joined: May 7th, 2006, 9:11 am
- Contact:
-
- Posts: 2225
- Joined: November 9th, 2004, 6:45 pm
- Location: Jakarta, Indonesia (UTC+7)
- Contact:
- GarethB
- Posts: 118
- Joined: May 7th, 2006, 9:11 am
- Contact:
- Grist
- Posts: 836
- Joined: January 27th, 2006, 9:20 pm
User scripts can only change web content. The extension itself would have to be modified. I did find a hack in the GM archives:
http://mozdev.org/pipermail/greasemonke ... 08766.html
It hasn't been thoroughly tested so I can't guarantee it won't break something. I tried it and it seems to work but I can't predict what might go wrong.
http://mozdev.org/pipermail/greasemonke ... 08766.html
It hasn't been thoroughly tested so I can't guarantee it won't break something. I tried it and it seems to work but I can't predict what might go wrong.
-
- Posts: 2225
- Joined: November 9th, 2004, 6:45 pm
- Location: Jakarta, Indonesia (UTC+7)
- Contact:
Ah, great! Then we can use userChrome.js script with WindowHook snippet.
Code: Select all
/* insert WindowHook snippet here */
WindowHook.register("chrome://greasemonkey/content/manage.xul",
function(aWindow) {
function populateChooser_sorted() {
var sortedScripts = aWindow.config.scripts.slice(0,aWindow.config.scripts.length);
sortedScripts.sort(
function(a,b) {
a=a.name.toLowerCase();
b=b.name.toLowerCase();
if (a < b) return -1;
if (a > b) return 1;
return 0;
}
)
for (var i = 0, script = null; (script = sortedScripts[i]); i++) {
var listitem = aWindow.document.createElement("listitem");
listitem.setAttribute("label", script.name);
listitem.setAttribute("crop", "end");
listitem.script = script;
if (!script.enabled) {
listitem.style.color = 'gray';
}
aWindow.listbox.appendChild(listitem);
}
}
aWindow.populateChooser = populateChooser_sorted;
}
);
Thanks, Grist
Last edited by Zoolcar9 on November 20th, 2006, 3:25 pm, edited 1 time in total.
- GarethB
- Posts: 118
- Joined: May 7th, 2006, 9:11 am
- Contact:
-
- Posts: 2225
- Joined: November 9th, 2004, 6:45 pm
- Location: Jakarta, Indonesia (UTC+7)
- Contact:
If you already have WindowHook snippet in your userChrome.js, you just have to copy the code above. If not, copy both (<a class="postlink" href="data:text/javascript,%2F*%20%3A%3A%3A%3A%3A%3A%3A%3A%20WindowHook%20%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%3A%20*%2F%0A%0Avar%20WindowHook%20%3D%20%7B%0A%09observe%3A%20function(aSubject%2C%20aTopic%2C%20aData)%0A%09%7B%0A%09%09if%20(!aSubject._WindowHook)%0A%09%09%7B%0A%09%09%09aSubject._WindowHook%20%3D%20this%3B%0A%09%09%09aSubject.addEventListener(%22load%22%2C%20this.onLoad_window%2C%20false)%3B%0A%09%09%7D%0A%09%7D%2C%0A%0A%09onLoad_window%3A%20function()%0A%09%7B%0A%09%09this.removeEventListener(%22load%22%2C%20this._WindowHook.onLoad_window%2C%20false)%3B%0A%09%09var%20funcs%20%3D%20this._WindowHook.mFuncs%5Bthis.document.location.href%5D%20%7C%7C%20null%3B%0A%09%09if%20(funcs)%0A%09%09%7B%0A%09%09%09funcs.forEach(function(aFunc)%20%7B%20aFunc(this)%3B%20%7D%2C%20this)%3B%0A%09%09%7D%0A%09%09delete%20this._WindowHook%3B%0A%09%7D%2C%0A%0A%09register%3A%20function(aURL%2C%20aFunc)%0A%09%7B%0A%09%09if%20(!this.mFuncs)%0A%09%09%7B%0A%09%09%09this.mFuncs%20%3D%20%7B%7D%3B%0A%09%09%09Components.classes%5B%22%40mozilla.org%2Fobserver-service%3B1%22%5D.getService(Components.interfaces.nsIObserverService).addObserver(this%2C%20%22domwindowopened%22%2C%20false)%3B%0A%09%09%7D%0A%09%09if%20(!this.mFuncs%5BaURL%5D)%0A%09%09%7B%0A%09%09%09this.mFuncs%5BaURL%5D%20%3D%20%5B%5D%3B%0A%09%09%7D%0A%09%09this.mFuncs%5BaURL%5D.push(aFunc)%3B%0A%09%7D%0A%7D%3B%0A">WindowHook</a> first, then the above code).