Wikipedia talk:User scripts/Archive 1
![]() | This is an archive of past discussions. Do not edit the contents of this page. If you wish to start a new discussion or revive an old one, please do so on the current talk page. |
Archive 1 | Archive 2 | Archive 3 | → | Archive 5 |
Are we making vandalism too easy?
While I do agree with, and intend to support, this project - I thought I should bring up the following concern: There is a well-founded concern on the pedia against bots - they are valued, and useful, but require various hurdles to be jumped through, out of fear of their power in the hands of bad apples. User scripts have some of the same powers and dangers. By making this project, are we making it too easy to get a semi-automatic vandalbot set up, and thereby opening up the pedia to Even More Vandalism? Any thoughts, comments, etc, would be much appreciated. JesseW 16:21, 13 August 2005 (UTC)
- I don't believe in security through obscurity. --malathion talk 21:17, 13 August 2005 (UTC)
- I don't generally believe in security through obscurity either, but I thought this might be such a time. But it's not a big concern, and it's really nice to have a central place to discuss making user scripts. JesseW 19:28, 14 August 2005 (UTC)
- Security through obscurity is good for stalling until you have real security, though. — Omegatron 06:36, 12 January 2006 (UTC)
Thanks guys
I've added "Add purge to tabs", "Add edit section 0", and "Changes since I last edited". They all work as advertised. My only complaint now is that at 800x600, I've now run out of tab "real estate" if I find another nifty script. :-( BlankVerse ∅ 06:23, 19 August 2005 (UTC)
- See "Add LI menu" - it lets you put tabs in a drop-down menu! Alphax τεχ 02:16, 27 August 2005 (UTC)
Wikipedia:Customisation
I've set up the Wikipedia:Customisation page which I would see as a great place to show off the best of what you guys come up with here. It contains some customisation options, but I've never really gone into the javascript and CSS of Wikipedia. Anything that you could do to help expand that page would be great – the intention is that it is a very simple description of how to customise the Wikipedia experience, particularly visual settings. violet/riga (t) 11:32, 3 September 2005 (UTC)
Towards a plugin system
Ok, finally managed to remember where I saw how to import chunks of code: User:Pilaf/monobook.js
To import eg. Pilaf's Live Preview, you do:
document.write('<script type="text/javascript" src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/livepreview.js&action=raw&ctype=text/javascript&dontcountme=s"></script>');
To create a "plugins" system, we'd need to write a function that can parse an array of pagenames and import the code from them - I'm sure it's doable, I just don't have the time right now... Alphax τεχ 07:00, 1 October 2005 (UTC)
- How about this?
function loadPlugins(list) { // list is an array or a comma-separated string var wpTitleBaseUrl='http://en.wikipedia.org/w/index.php?title='; var wpEndScriptUrl='&action=raw&ctype=text/javascript&dontcountme=s'; if (typeof list == 'string') list=list.split(','); for (var i=0; i<list.length; ++i) { document.write('<script type="text/javascript" src="' + wpTitleBaseUrl + encodeURI(list[i]) + wpEndScriptUrl + '"></script>'); } };
- (untested) Lupin|talk|popups 15:49, 1 October 2005 (UTC)
- Looks like it might work, but yeah, need to test it... preferably on some protected (or userspace) pages... Alphax τεχ 14:21, 4 October 2005 (UTC)
- I tried it out and it did not quite work as I'd expected, though that says probably more about my expectations. I added the following to my monobook.js
- Looks like it might work, but yeah, need to test it... preferably on some protected (or userspace) pages... Alphax τεχ 14:21, 4 October 2005 (UTC)
loadPlugins('Wikipedia:WikiProject_User_scripts/Scripts/Force_edit_summary'); window.addEventListener('load', addForceSummary, false);
- Result: my browser complains that addForceSummary is not defined. I guess this is because the Force Edit Summary page, which contains the function, is loaded too late.
- Some questions about the loadPlugins function:
- Performance implications? If you use loadPlugins, do you need to load that page every time you load a Wikipedia article (this would be bad), or is it cached (then, using loadPlugins would reduce the amount of JavaScript on every page, so the pages become shorter -> good).
- Security. If I use loadPlugins, then any editor can do terrible things just be editing the page I load, correct? Can we mitigate it?
- What does "dontcountme=s" in the URL do?
- Is encodeURI() a standard function and what does it do? Related to this, does anybody know a good JavaScript resource? I only know [1] (there is also Dive Into GreaseMonkey which contains some useful tips), but they don't treat e.g. regular expressions. Or should I buy a book?
- Thanks, Jitse Niesen (talk) 14:04, 22 October 2005 (UTC)
- Yes, there will always be problems with a plugin system like this in my opinion unless we can figure out how to make the scripts that are loaded execute in the order in which they are loaded. Browsers seem to rely on scripts being independent of one another, and execute them in unpredictable orders. So my function is way too naive.
- It seems to me that what we really want is a preprocessor, so that you could say
#include [[Wikipedia:WikiProject_User_scripts/Scripts/Force_edit_summary]]
- in a pseudo-javascript file, and then run the preprocessor over that file to create a single huge javascript which transcludes that file and any other #included files. Then you'd load the huge file from your monobook.js or paste it in directly. This could be automated in javascript, I think. Addressing your questions:
- Performance implications are bad, in that the browser gets the headers tends to cache the content. In practise, this can make a big difference when wikipedia is under heavy load. Using a monolithic file would help here.
- All javascript on wikipedia that's unprotected and not in userspace is vulnerable to editing. Page protecting is the best way around this I think.
- I'm not sure what dontcountme=s does - it could be something to do with mediawiki's bandwidth throttling, but that's a guess. I copied it from livepreview before I really knew what I was doing at all, and it hasn't broken anything, so it's stayed ever since.
- encodeURI is indeed a standard function. For learning JS, I'd recommend the first few chapters of the rhino book, #javascript on irc.freenode.net, and some other stuff online:
- Mozilla JavaScript Documentation
- Using the XML HTTP Request object
- JavaScript RegExp Object - Using Regular Expressions with Client Side Scripting
- svendtofte.com - Learning the JavaScript debugger Venkman
- User:Korath/standard.js - Wikipedia, the free encyclopedia
- User:Cryptic/standard.js - Wikipedia, the ::::*free encyclopedia
- Quirksmode
- OOP in JS, Part 1 : Public/Private Variables and Methods
- Lupin|talk|popups 00:22, 31 October 2005 (UTC)
- in a pseudo-javascript file, and then run the preprocessor over that file to create a single huge javascript which transcludes that file and any other #included files. Then you'd load the huge file from your monobook.js or paste it in directly. This could be automated in javascript, I think. Addressing your questions:
I've given this quite some thought and I wrote the function at the bottom Mediawiki talk:monobook.js to encapsulate the inclusion and provide rudimentary configuration, but that just solves a small part of the problem. See my monobook.js to see it in some action. Thoughtful coding of scripts could make scripts load in the right order (some juggling of include calls would do the trick). The real solution of this problem, of course, is to have ordinary transclusion, just like other pages, i.e. {{user:lupin/popups.js|structure=menus}}. I recently suggested that this be enabled, but was told that it's not secure. Is it more unsecure than what we're doing now? Zocky 13:46, 1 November 2005 (UTC)
Would the code below help at all at getting things to load in order? I'm playing around with something similar at wikisource. However, I really don't know much about javascript/browsers. Derex 18:42, 19 December 2005 (UTC)
if (window.addEventListener) window.addEventListener('load', plugin_hook, false); else if (window.attachEvent) window.attachEvent('onload', plugin_hook); function loadScript(name){ script = document.createElement('script'); script.src = 'http://en.wikipedia.org/w/index.php?title=SCRIPT_REPOSITORY/'+ name +'.js&action=raw&ctype=text/javascript&dontcountme=s?'; script.type = 'text/javascript'; document.getElementsByTagName('head')[0].appendChild(script); } function plugin_hook() { loadScript('script1'); loadScript('script2'); }
PS: I noticed someone raised the issue of whether one disgruntled admin could sabotage the whole system by trojaning the plugins ... making other admins delete stuff unknowingly, etc. You can make subpages off of your user monobook.js ... these are protected just like the main page (on WS anyway). So, you could plugin off a single user's space ... that way only one admin could sabotage the system. It would be a little inconvenient if that person left, because all the users would be pointing at the wrong (unmaintained) page ... not a huge deal to fix though. Derex 18:58, 19 December 2005 (UTC)
- Admins can also change the monobook.js of other users, so that won't help. -- Jitse Niesen (talk) 19:25, 19 December 2005 (UTC)
- Such an admin would be immediately caught and
shotdesysopped, though. Titoxd(?!? - did you read this?) 19:28, 19 December 2005 (UTC)- I was going to say something, but maybe we shouldn't be talking about this in public? — Omegatron 06:42, 12 January 2006 (UTC)
- Such an admin would be immediately caught and
Peer Review, external
Been fiddling with code from here and a few other places, and some of my own, on Uncyclopedia, thought I might ask for comments on it (link). Most of it is pretty self explanatory. addblockuser() gives me a "Block user" button (on uncyc) on Special:Contribs (for /wiki/ and for /index.php/ versions of the link). MTU is a macro, and could be modified to add a template or any text to a page pretty easily. Something I can't figure out how to do is add or change the edit macro buttons (bold/italic/sig/etc), but it looks unlikely to be very editable as it is embedded in the html and not an external script.... thoughts? Splarka (rant) 04:59, 18 October 2005 (UTC) (long time javascript noob)
- Update: I have found a simple way to modify your edit window macro buttons. It has lots of possibility.
Tangent: I've figured out how to change the title and link of the top "personal" links, but does anyone know of a way to add to them?Nevermind, found a way. Splarka (rant) 11:32, 20 October 2005 (UTC)
Sidebar links
It's funny to see my toolbox links described as "interesting" here. I don't really recommend copying them though. I once used a screenshot of Wikipedia with my javascript and CSS applied in a presentation as an example of what can go wrong when you let users edit the site's style and navigation by themselves since it really is a mess, especially when you scroll down a page with interlanguage links on it. If there's an easier way to add a bunch of links (internal and external) to the sidebar, I'd like to know about it. :) Angela. 05:44, 22 October 2005 (UTC)
- Here's what I use:
/**** Add links to the toolbox ****/ function addToolBoxLinks() { var tb = document.getElementById('p-tb').getElementsByTagName('ul')[0]; var afdtime = new Date(); var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; afdtime.setUTCDate(afdtime.getUTCDate() - 7); addlilink(tb, '/wiki/Special:Newpages', 'New pages', ''); addlilink(tb, '/wiki/Special:Shortpages', 'Short pages', ''); addlilink(tb, '/wiki/Special:Log', 'Logs', ''); addlilink(tb, '/wiki/Template:Deletiontools', 'Deletion tools', ''); addlilink(tb, '/wiki/Wikipedia:Articles_for_deletion/Log/' + afdtime.getUTCFullYear() + '_' + months[afdtime.getUTCMonth()] + '_' + afdtime.getUTCDate(), 'Week old AfD', ''); addlilink(tb, '/wiki/Wikipedia:Disambiguation_pages_with_links', 'Dab list', ''); addlilink(tb, '/wiki/Wikipedia:Template_messages/User_talk_namespace', 'Talk messages', ''); addlilink(tb, '/wiki/User_talk:Alphax/special', 'Special characters', ''); addlilink(tb, '/wiki/User:Alphax/Sandbox', 'My sandbox', ''); addlilink(tb, '/wiki/WP:ICT', 'Image Copyright tags', ''); }
- Bit messy (you need addlilink), but it works. Just call addToolBoxLinks() somewhere in your onload function. Alphax τεχ 12:12, 4 November 2005 (UTC)
Available skillset
Hi everyone! Would it be possible for us to summarize the skillset we have in this group with respect to software engineering and programming experience? There are a number of interesting scripts here, and I think this project would benefit greatly if we did some brainstorming to see what sort of things this project intends to support for Wikipedia. --HappyCamper 14:05, 30 October 2005 (UTC)
merge
Umm no. Have you seen how much content is spread accross those pages? they were broken down for a reason.Geni 15:09, 6 November 2005 (UTC)
- Wikipedia:Kate's Tool is very much a user script. -- Zondor 17:03, 6 November 2005 (UTC)
- Wikipedia:Tools/Navigation popups is all about user scripting -- Zondor 17:06, 6 November 2005 (UTC)
- Wikipedia:Tools/Editing Tools has a couple of user scripts. -- Zondor 17:10, 6 November 2005 (UTC)
- Wikipedia:Tools/Misc Other mentions several user scripts -- Zondor 17:15, 6 November 2005 (UTC)
- I find many of the merge suggestions unnecessary. I'm hesitant to move much content under the Wikiproject, it be linked from here. Rather, why not keep it on well titled pages (Tools/xxx) and use this project as a rallying point to manage it. The tree should be something like this?
- Tools (see also meta links)
- Wiki-side (monobook.js/css) (re-title)
- Nav Popups, godmode, etc
- Browser-side (greasemonkey, etc)
- IRC
- Database
- Stats and analysis
- Standalone tools (
- Kate's Tool? (also include above integrated with Nav Popups)
- CryptoDerk's Vandal Fighter (CDVF)
- User:Gerbrant/WikiCheck
- Wiki-side (monobook.js/css) (re-title)
- Tools (see also meta links)
- ∴ here…♠ 18:10, 6 November 2005 (UTC)
- I find many of the merge suggestions unnecessary. I'm hesitant to move much content under the Wikiproject, it be linked from here. Rather, why not keep it on well titled pages (Tools/xxx) and use this project as a rallying point to manage it. The tree should be something like this?
It's a great deal easier to type in WP:KT into the URL than to wade through a Wikiproject, so I oppose merging Kate's tool here. (No comment on others.) Ingoolemo talk 07:08, 7 November 2005 (UTC)
Okay, perhaps its too expensive to move. But, the premise is to have good organisation and neatness. It would be great if there can be Wikipedia:User scripts where all users scripts are stored, also within subpages and point links to user scripts from there. Wikipedia:Scripts currently stores general ones. Wikipedia:Tools stores others. Perhaps, it is a good idea to store the database/repository of scripts and tools in this way. And as mention this project serves as a rallying point. -- Zondor 08:54, 7 November 2005 (UTC)
- Wikipedia:Scripts is mostly not about the same sort of scripts as we have here. It's mostly about scripting for external software to work with Wikipedia. All these, I agree with here, should go under Wikipedia:Tools. But these shouldn't just be organised by type, but more importantly by purpose. jnothman talk 14:01, 7 November 2005 (UTC)
- All good ideas, conversation paraphrased at WP:TOOLS here. Lets leave the WP:TOOLS conversation there and use this project to focus on user scripts, and how to integrate their organization with the rest of Tools. I am removing most of the merge notices when I come across them.
- Zondor, m:Help:User style is help about what we are calling User scripts. Do you think Wikipedia:User style or Wikipedia:User scripts ? ∴ here…♠ 18:23, 7 November 2005 (UTC)
Updatable Javascripts
I asked in Wikipedia_talk:Tools#updatable_Javascript and they recommended here.
I was thinking we should have a centralized place for user scripts to be stored that can be imported into user's profiles (like Lupin's popups, for instance) instead of copied and pasted, which would allow them to be updated in a central location and propagated to everyone. If the pages were protected, this wouldn't be any less secure than having Mediawiki:monobook.js admin-editable.
(Speaking of which, couldn't a disgruntled admin write a script on there that would make other admins delete images or other such serious vandalism without their knowledge?) — Omegatron 00:19, 8 November 2005 (UTC)
- Absolutely, they could. One way around this would be to link to specific trusted revisions of scripts, although this means they have to be manually updated when the script changes with bugfixes, new features (or new trojans, which rather defeats the point, I suppose). Lupin|talk|popups 03:34, 6 January 2006 (UTC)
- Using include-type functions, could you write a function to include a specific revision of a user script instead of the latest version?
- If so, you could probably write one that would let you update it manually to the latest version, or like show you which scripts have newer versions and let you see the diff, etc. — Omegatron 16:38, 10 January 2006 (UTC)
- Yes, including specific revisions is easy, whether in an include-type function or not. Lupin|talk|popups 12:16, 14 January 2006 (UTC)
- There's no more risk of a disgruntled admin doing it that way instead of just editing a person's monobook.js file directly since admins can modify anyone's .js files. Pegasus1138Talk | Contribs | Email ---- 20:11, 26 February 2006 (UTC)
Picture Popups
I've written a new js tool for images, see User:Zocky/Picture Popups. Testers and comments are welcome. Zocky 04:19, 9 November 2005 (UTC)
Add/Remove to side bar?
Hello all you programmers! I have a quick question: does anyone know the source of code that removes/adds links in the side bar (i.e. navigation and toolbox)? I've seen it done before, but can't seem to find it now. Thanks! Flcelloguy ( A note? ) 00:07, 12 November 2005 (UTC)
- See Wikipedia:WikiProject User scripts/Scripts#Helper functions under "Add toolbox link". Can be generalised more. jnothman talk 13:14, 12 November 2005 (UTC)
Idea
What I think would be the most effective is to create a "Pick and choose" script database, where a user with negligible javascript experience can go and add the features he likes for his own monobook.js, by copying a "standard framework" monobook and adding from there. An example would be:
Tabs
- The following functions are available as tabs, you just need to paste them in the
//tabs
section of your Javascipt file:
- Purge
- Close AFDs
- ...
Toolbox
- The following functions are available as links in the toolbox, you just need to paste them in the
//toolbar
section of your Javascipt file:
- Editcount for other users
- Block log
- Block link
- Unblock link
- User log (deletions, protections, moves...)
- ...
Userlinks
- The following functions are available as links in the top part of your screen (next to log out), you just need to paste them in the
//userlinks
section of your Javascipt file:
- My Kate's Tool
- ...
That's just my idea... Titoxd(?!?) 02:48, 16 November 2005 (UTC)
- I was thinking something similar. If the user includes code to import some Wikipedia:WikiProject_User_scripts/library.js file, we could implement it such that they only then need a series of lines like:
install('purge tab'); installe('afd helper', 'afdh_signature=[[user:me|mysig]]');
- and librry.js would handle the importing of necessary files and functions, with itself containing the most common features, and including other scripts where necessary. It would mean that the form of scripts would have to be standardised. It would also require library.js to be locked from vandalism once available and in use (so I couldn't edit it either, but we'd obviously need a place where requested additions could be made). jnothman talk 03:25, 16 November 2005 (UTC)
- I think a technical hitch here is that if library.js defines some functions, then in order to use those functions in another javascript file, it's not enough to import library.js with document.write, since javascript files are not loaded instantly - they only seem to be guaranteed to be loaded by the time the entire page finishes loading, by which time it's too late to include other javascript files with document.write.
- One way around this would be to give users an "easy mode" of editing their monobook.js. Then the installation functions could be loaded in a document.write when users go to edit their monobook.js and users could select scripts with point and click. The javascript itself could optionally be hidden and managed entirely by the script. There's some code which attempts to do the code management part of this (no UI yet) in a probably highly suboptimal manner at User:Lupin/scripter.js. Lupin|talk|popups 12:26, 14 January 2006 (UTC)
Newbie help
I cut and paste the demo script into my monobook.js page and reloaded but it does not seem to work (when I go in to edit a page I do not see a 'wikify' tab). My monobook.js page is the only one I have seen without the message bout reloading, so I wonder if I have done something stuid. Any ideas? IanBailey 08:14, 16 November 2005 (UTC)
- My guess is that you forgot the
cssmods required to make that script work. If you double check Wikipedia:WikiProject_User_scripts/Scripts, you will see two helper functions required to make the wikify script work (right hand column of the table). Try adding the following toUser:IanBailey/monobook.cssUser:IanBailey/monobook.js: - Good luck, please ask if it don't work! ;) ∴ here…♠ 09:27, 16 November 2005 (UTC)
Ian is right that this is not explained very clearly in Wikipedia:WikiProject User scripts/Tutorial. As User:here says, you need to include the helper functions as well (except that they are also JavaScript, and not CSS). So, User:IanBailey/monobook.js should look like
function addlilink(tabs, url, name, id, title, key){ var na = document.createElement('a'); na.href = url; na.appendChild(document.createTextNode(name)); var li = document.createElement('li'); if(id) li.id = id; li.appendChild(na); tabs.appendChild(li); if(id) { if(key && title) { ta[id] = [key, title]; } else if(key) { ta[id] = [key, '']; } else if(title) { ta[id] = ['', title]; } } // re-render the title and accesskeys from existing code in wikibits.js akeytt(); return li; } function addTab(url, name, id, title, key){ var tabs = document.getElementById('p-cactions').getElementsByTagName('ul')[0]; return addlilink(tabs, url, name, id, title, key); } function addQwikify() { addTab("javascript:doQwikify()", "wikify", "ca-wikify", "Mark for wikification", ""); } function doQwikify() { document.editform.wpTextbox1.value = "{"+"{wikify}}\n\n" + document.editform.wpTextbox1.value; document.editform.submit(); } if (window.addEventListener) window.addEventListener("load", addQwikify, false); else if (window.attachEvent) window.attachEvent("onload", addQwikify);
I have no idea why you do not get the message about reloading. Cheers, Jitse Niesen (talk) 12:03, 16 November 2005 (UTC)
- Thanks Here/Jitse. That makes sense and now it works as advertised. Cheers IanBailey 10:30, 17 November 2005 (UTC)
- I had the same problem about not getting the reloading message, and not getting the code in a dotted-border box. So have other people... However, the script did work for me after reloading the cache. Anyone know what this is? A bug? If so, where should it be reported? /Skagedal 22:12, 27 November 2005 (UTC)
- I think I asked about the same problem here. — Omegatron 15:43, 14 January 2006 (UTC)
ARIN WHOIS
Who has added a tab to his monobook.js to add a link to ARIN's WHOIS utility. Is there a way someone with more technical ability than me can add it to my Monobook.js? Thanks... Titoxd(?!?) 01:50, 24 November 2005 (UTC)
I have an idea for a tool...
Hi, I like what you guys are doing here. I hope this is the right place to ask this. I have an idea for a tool that will basically just print a text representation of a tree representation for a given category. You can see what I mean here (this is one I did by hand, it's not great anyway - and it's not consistent). If I am interested in a given topic I find it useful to know what subcats exist without going through them all by hand. I would also find this very useful on commons, for categorising images. For example I would like to run it on commons:Category:China. It would also allow you to more easily see obvious gaps (for example, missing provinces of China).
I wrote a brief algorithm for it here: User:Pfctdayelise/Texttreeofcats. But I don't know how to implement it. I don't know javascript (but I suspect it is not quite the right tool for this anyway). I know Python, but I am not (yet) familiar with the pywikipedia stuff. I also suspect it is not quite what I want.
Also, I know we are not allowed to run spiders over the wikipedia live; you have to use a database dump, yeah? I guess this is a kind of spider but would I be able to run it live? Since it's not editing pages, and it has definite limits, I don't think it would be that onerous. And I would only run it every now and then, and then save the resulting text tree for reference.
So, any advice about implementing this you could give me, would be great. Please reply here or on my Talk page. Thanks!
--pfctdayelise 02:29, 26 November 2005 (UTC)
- Beland's bot Pearle can do this. He's usually happy to take requests, or you can get a Pearleclone running (not a trivial task). —Cryptic (talk) 03:16, 26 November 2005 (UTC)
- OK great! I made a request. What about if I wanted to implement this myself rather than bug User:Beland every time I want a report? Could I do it? It seems Pearle has lots of other functionality I'm not really interested in. pfctdayelise 03:55, 26 November 2005 (UTC)
- Someone else has developed a tool to do this for commons and de:, see the commons one here. pfctdayelise 04:43, 5 December 2005 (UTC)
Request for script
Hi. I have a request. When checking my watchlist, the most annoying thing is when several changes to a given article occured in the last say 24 hours. Then doing a diff is not enough, one needs to go to the history, select a range, and see the total diff.
My request would be the following. Can one fool the diff button to show not just the last diff, but the diffs in the last 24 hours combined? Or to have several diffs show up one under another on the watchlist?
A similar feature exists for recent changes (one needs to enable that one in the preferences), but not for the watchlist. If anybody has any suggestions, that would be very much appreciated (I could do the coding in Javascript or whatever myself, but I don't even know how to start). Oleg Alexandrov (talk) 05:12, 2 December 2005 (UTC)
- There's already a "show changes since I last edited" script out there (somewhere, shouldn't be too hard to locate). This may do what you want already, or be easy to adapt. Lupin|talk|popups 05:14, 2 December 2005 (UTC)
- Hypothetically: A right-click popup window over the (hist) on a watchlist page, could load that history page and filter it to only show "(cur)", the date, and the nick (with only the "cur" clickable). Might be doable and relatively unobtrusive (maybe). Splarka (rant) 08:38, 2 December 2005 (UTC)
- I found that, at Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited. But it does not work. It just shows an error in red, and that's it. :( Oleg Alexandrov (talk) 01:11, 3 December 2005 (UTC)
- To reply to Splarka, yes indeed, might be doable, and as you say, with some kind of popup. The best thing to do would be I think combining the download feature of Lupin's popups with the history parsing code at Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited (but again, the latter does not work). Might involve a lot of javascript (I got scared looking at the source of Lupin's popups). I plan to do it as a long-term project, although if somebody wants to help, help is very welcome. :) Oleg Alexandrov (talk) 20:17, 5 December 2005 (UTC)
- I found that, at Wikipedia:WikiProject User scripts/Scripts/Changes since I last edited. But it does not work. It just shows an error in red, and that's it. :( Oleg Alexandrov (talk) 01:11, 3 December 2005 (UTC)
- Hypothetically: A right-click popup window over the (hist) on a watchlist page, could load that history page and filter it to only show "(cur)", the date, and the nick (with only the "cur" clickable). Might be doable and relatively unobtrusive (maybe). Splarka (rant) 08:38, 2 December 2005 (UTC)
- I've done something like this in the dev version of popups in response to a recent request. Lupin|talk|popups 04:25, 28 January 2006 (UTC)
Ease of use
It seems that we should try to make user scripts easier to use; this is also one of goals of this WikiProject. A plugin system, outlined for example in #Idea, would be a start. In an effort to simplify it further, how about creating a form where the user just clicks the options to be included? I wrote a mock-up at [2]. Do you think that could be useful?
At the moment, it just generates the user script. I intended to make another button for uploading the script to Wikipedia. However, this is not so easy. If the uploading is done by a server-side program, the user has to give the Wikipedia password to my site, which many will rightfully find a bit scary. However, it cannot be done by JavaScript because of the Same Origin Policy (a script can only access web pages from the same site as where the script originates). This problem can be avoided by using signed scripts, but that sounds awfully complicated and will only work on Mozilla. Any ideas? -- Jitse Niesen (talk) 00:08, 3 December 2005 (UTC)
- We could run a plugin system on en.wikipedia.org. Then the page-editing could be done either server-side or with javascript. Lupin|talk|popups 00:15, 3 December 2005 (UTC)
Hmm. Anything I can think of requires a lot of cooperation from developers, which will not be that easy to get (besides, I have another thing that I want to push at some point). It might just be possible to do something via the JavaScript that admins can edit, but I can't readily see a way to achieve this in a reasonable safe manner. Do you see a way to do this?
On the other hand, I see that almost 500 people have installed your popups (including some IP addresses; I thought they couldn't?), so perhaps it's not too much to ask people to copy the script from the edit box to their monobook.js. By the way, thanks for recommending the O'Reilly book on JavaScript; it's been useful. -- Jitse Niesen (talk) 01:26, 3 December 2005 (UTC)
- We can install site-wide javascript in Mediawiki:monobook.js. We could create functions that spring into life when you visit some particular page, such as Wikipedia:Plugins or Special:Preferences. For example, we can create an interface which allows you to easily modify your js file. Lupin|talk|popups 13:04, 5 December 2005 (UTC)
That might work, yes. I don't want to add a lot of JavaScript to Mediawiki:monobook.js, but we can check whether we're on a special page and pull in the script if we are. -- Jitse Niesen (talk) 14:20, 5 December 2005 (UTC)
- I have some code that manages your user javascript file. I wrote this a while ago and got fed up with it, but it may come in handy. To run the test function/demo, you have to load it somehow, edit your monobook.js file and type javascript:testScripter() in the address bar. The idea is that it inserts a special chunk of javascript which it can parse later to insert and remove chunks of code. The chunks are stored on the wiki and loaded by the script, which refers to specific revisions for security. Lupin|talk|popups 03:47, 6 January 2006 (UTC)
Request and help
I want to use this script as a tab to get the title of the page and copy that to my clipboard (for easy pasting) or to maybe make the Location Bar equal the title so I can just highlight that and copy it. Is that possible? I'm not familiar with scripting...
Also, is there a script that will search the textarea when I'm editing? Firefox doesn't do it and I only see a replace script. I can't imagine it'd be that difficult, but what do I know. A bookmarklet would also suffice. Thanks, I appreciate any help. BTW, I'm using Firefox. Gflores Talk 18:37, 5 December 2005 (UTC)
- Did you see Lupin's reply? -- Jitse Niesen (talk) 09:43, 6 December 2005 (UTC)
monobook.js won't work
I used to use my monoboox.js to create a Kate link in the top (with my watchlist, contributions, etc.). That stopped working and when I recently added a new script, it still didn't work. I have no idea of how to write HTML/CSS. Thelb4 17:54, 6 December 2005 (UTC)
- HTML and CSS don't really come into play here: we're working with javascript. While, without spending too much time to work out why your first script stopped working, the reason that your second script didnt' come into effect may be that you didn't refresh your browser's cache. Whenever you update monobook.js, you have to visit http://en.wikipedia.org/w/index.php?title=User:Thelb4/monobook.js&action=raw&ctype=text/javascript&dontcountme=s and refresh the page. Now looking at your monobook.js, there is a problem in that you have the line "{ border: 2px solid blue; }" there which is not javascript (it is nearly CSS). Remove this line before anything else. jnothman talk 22:30, 6 December 2005 (UTC)
- I can't go to that page - when I click on it, it asks me to open Microsoft Picture It!. When I do, it says that it can't open the file. Thelb4 07:49, 7 December 2005 (UTC)
- Hang on a sec, my first script is working! Thelb4 07:51, 7 December 2005 (UTC)
- Right, so maybe just go to the normal monobook.js and refresh it as instructed. I haven't tried going to that page in IE. jnothman talk 08:46, 7 December 2005 (UTC)
My user scripts are acting up. Without making any changes to them, my Kate's tool link and an editing tab appeared and then disappeared. I can't figure out what is wrong. I was wondering if a kind soul would review my monobook.js and see if they could diagnose the problem.
Important to surround scripts by <pre> tags
Hi all, I just wanted to note that all scripts available for others' uses should be preceded by
//<pre>
and followed by
//</pre>
Users that have been copying the text of the google link script, for instance, have been copying title.replace(/("|%22)/g, ) because the internal code was title.replace(/("|%22)/g, '') which then showed without the '' because this was treated as markup. jnothman talk 22:55, 11 December 2005 (UTC)
- <nowiki> is good, too. Lupin|talk|popups 04:04, 14 December 2005 (UTC)
- Ideally, shouldn't <code> do both? — Omegatron 02:20, 12 January 2006 (UTC)
- That'd mean you couldn't have links or other markup inside code. — 82.46.154.93 07:34, 26 February 2006 (UTC)
Logs link
I added a new script, Wikipedia:WikiProject User scripts/Scripts/Logs link. It adds a link to the toolbox which goes to Special:Log for that page. If the page is a user page, user talk page or user subpage, then the link will go to logs for that user. --bainer (talk) 04:04, 23 December 2005 (UTC)
Animated sidebar swapper
I saw an example of a fade in/out javascript animation somewhere, and got the bright idea that I needed to put something like it somewhere in my Wikipedia interface. The result is a script that turns the Wikipedia logo into a toggle switch that swaps two sets of 'portlet' boxes.
Tested in some Mozilla-derivatives, probably breaks in damn near everything else.
Written for my myskin.css, which is close enough to Monobook that there shouldn't be any problems dropping it in.
See User:Cyrius/myskin.js, SwapColumns() -- Cyrius|✎ 06:58, 6 January 2006 (UTC)
Including scripts
What is the quickest, most efficient way of including other people's scripts in mine? Lupin's popups uses a piece of code to include it in your js and be updatable, etc. User:Quarl/monobook.js uses a similar thing inside a function to keep his monobook.js very clean:
function winc(s) { document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=' + s + '&action=raw&ctype=text/javascript&dontcountme=s"></script>'); }
I want to do the same thing for mine, and start putting all my individual functions on different pages, but is this the best way to do that? — Omegatron 16:23, 10 January 2006 (UTC)
- Here's a piece of untested hackery you may like to try. Make a new page User:Omegatron/inclusions.js which looks like this:
{{User:Omegatron/function1.js}} {{User:Omegatron/function2.js}} ...
- and then in your monobook.js, type
document.write('<script type="text/javascript" src="' + 'http://en.wikipedia.org/w/index.php?title=User:Omegatron/inclusions.js' + '&action=raw&templates=expand&ctype=text/javascript&dontcountme=s"></script>');
- This relies on the templates=expand parameter expanding templates in pages fetched with action=raw. The theoretical advantage is that only two javascript files, monobook.js and inclusions.js are actually loaded by the browser. This may or may not be more efficient than the traditional method. Lupin|talk|popups 03:10, 12 January 2006 (UTC)
- Uh oh, too late. :-) I just finished using the winc function to include them all. I'm still learning this stuff. I put the individual functions as subpages of my monobook.js, and now it has a monobook.js link at the top of each one, which is convenient and logical. See User:Omegatron/monobook.js/mathcharacterfixer.js, for example. — Omegatron 06:22, 12 January 2006 (UTC)
- It sort of works, but not perfectly. It tries to parse math tags and template markup inside the scripts, for instance (like a script that puts a template into an article.) I'm not sure what to do with it. — Omegatron 19:44, 18 January 2006 (UTC)
- Yes, you'd have to split up those things in scripts that you want to include with this technique - something like mathStart='<math'+'>', function template(x){return '{'+'{'+x+'}'+'}';} etc etc etc. Lupin|talk|popups 01:02, 19 January 2006 (UTC)
Fixed sidebar
A while ago, I figured out some kludgy css to make the sidebar stay in the same position while you scroll, so it's always accessible. This is what mine looks like right now: — Omegatron 07:56, 12 January 2006 (UTC)
- I figured it out now that I know some css. :-) I'll post here after I've tested it for a few days. — Omegatron 03:13, 4 February 2006 (UTC)
Non-intrusive notification
Is there non-intrusive alternative to the alert() box? Something non-modal? They really annoy me. I guess the background color could be changed or something to at least indicate an error... — Omegatron 07:30, 14 January 2006 (UTC)
- In a tab-based script, I used this to change the background color of the tab when clicked, to indicate without interrupting that there is no action to perform:
document.getElementById('ca-unverified').firstChild.style.backgroundColor = "#ff4444"; document.getElementById('ca-unverified').style.backgroundColor = "#ff4444";
- (Both statements were needed for me to look right with rounded-corner tabs.) See User:Omegatron/monobook.js/unverified.js — Omegatron 08:51, 14 January 2006 (UTC)
- This is a cute way of "fixing" alert in whatever way you desire. http://slayeroffice.com/code/custom_alert/ Lupin|talk|popups 12:32, 14 January 2006 (UTC)
Testing scripts?
Hi all. I'm about to start writing a script that makes image tagging easier, and I was looking for some advice on how to test it. I think testing tips would be a valuable addition to the techniques page. ~MDD4696 03:39, 23 January 2006 (UTC)
New template for tool installation
I've generalised {{navpop}} to give a new template, {{js}} for easy installation of scripts. Lupin|talk|popups 23:48, 25 January 2006 (UTC)
Ease of use, part II
Following up on #Ease of use, and especially on Lupin's comments (though I still need to study his code to see where mine can be improved), I made another version on Wikipedia. If you want to have a look (and please do), this is what you need to do:
- Add the following fragment to your monobook.js (if something like this is eventually adopted, this can be put in Mediawiki:monobook.js):
if (location.href == "http://en.wikipedia.org/wiki/User:Jitse_Niesen/Client-side_preferences") {
{{subst:js|User:Jitse_Niesen/Client-side_preferences/Main.js}}
}
- Go to User:Jitse Niesen/Client-side preferences.
- Choose the scripts you want to have (there is not much choice at the moment) and press the button.
Three warnings: It works in my configuration but it might not work in orther ones, your old user script is overwritten, and the script for the "since" tab does not work for me.
I'm curious what you think of it. -- Jitse Niesen (talk) 02:06, 28 January 2006 (UTC)
Tracking abuse in recent changes
I have recently written a Python script that reads the atom feed of the recent changes and reports whether there were edits containing suspicious words such as '!!!' or 'rulez!'. I have asked Brion about whether this feature is going to be introduced anytime to the recent changes page, and he told me it is on the feature list but not for the near future.
The question is whether there is such a program already in existance, that tries to identify abuse on pages, and I am wasting my time? If there are such scripts or programs, I would appreciate a link to them.
My little script can be found here: http://he.wikipedia.org/wiki/%D7%9E%D7%A9%D7%AA%D7%9E%D7%A9:Gloomy/WikiPolice
Omer Enbar 23:37, 30 January 2006 (UTC)
Some help
I tried adding test-n.js into my monobook but it won't work on IE or firefox. Some help? Thanks.--Urthogie 10:50, 1 February 2006 (UTC)
- A curly brace was missing; see this diff. Can you fix it yourself in your monobook or do you want me to fix it for you? -- Jitse Niesen (talk) 12:56, 1 February 2006 (UTC)
- I got it, thanks!--Urthogie 14:17, 1 February 2006 (UTC)