|Wikipedia: The Missing Manual (Discuss)|
Setting up your browser
How you check the settings depends on your browser:
Adding and deleting scripts
1. On your user page, click "edit this page". In the edit box, type either *[[User:YourUsernameGoesHere/common.js]] or simply *[[/common.js]]. Then add an edit summary like Creating link to new common.js page, do a preview, and then save your edit.
- By saving the page with only a comment, initially, you're creating a version of the page that you can revert to if something goes wrong. That's extremely unlikely, but it doesn't hurt to have the option.
Adding a script
1. Go to the page Wikipedia:WikiProject User scripts/Scripts/User tabs (Figure 21-2), and copy all the text within the dotted box.
2. Open your own common.js page, and then, in the edit box, paste the text that you copied in step 1.
- If you haven't created a common.js page yet, instructions are on the section about xx.
3. Change [[User:Where/usertabs]] to [[Wikipedia:WikiProject User scripts/Scripts/User tabs]], to show where you got the script.
- Your edit box should look like Figure 21-3.
- The preview should look like Figure 21-4. If everything looks as you expect (as is the case here, there's no visible change), save the page. If something looks wrong, recheck the code that you added to the page.
5. After you save the change, you should bypass your cache so that Wikipedia isn't using an old version of your common.js (see the section about xx). Then go to a page where you expect the change to appear—for example, click on the "my talk" link on the upper right, and check if the change has happened.
- As shown in Figure 21-5, it indeed has.
If you still can't see what you expect after bypassing your cache, then ask for assistance at the Help desk (shortcut: WP:HD).
Preventing code overload
It's good practice to put anything other than a very short script into a separate page, with a name ending in .js, so that only you—and administrators—can edit it. That way, you don't end up with a very long, difficult-to-understand and difficult-to-edit common.js page.
Importing multi-function scripts of other editors
Several Wikipedia editors have created big, fabulously useful, multi-function scripts. You absolutely don't want to cut and paste these scripts, even to a separate page of your own, because you need the editor who created it to maintain it. You want to get enhancements to the code as they occur. By using the import function, you get the benefit of those updates (as do the hundreds of other editors using the same script).
As you can see from reading this chapter, editing your common.js page is no big deal. It's no harder than cutting and pasting text to any Wikipedia article. You can remove a function by deleting it, or by commenting it out (putting a pair of slashes at the beginning of each line). Commenting out works best for cases where you're importing a function (see Figure 21-7) and there's just one line to comment out. If you have 10 or 15 lines of code that you copied to your common.js page that you don't want any more, the page will be a lot neater if you delete it all, perhaps leaving a single comment line about where you found the code, in case you want to copy it back in at some later point.
- You may need to bypass your browser's cache (the copy of pages that it keeps, to speed up the process of showing you what you want to see):
- Internet Explorer. Press Ctrl+F5.
- Mozilla Firefox. Press the Shift key while clicking the Reload button (or press Ctrl+Shift+R).
- Opera/Konqueror. Press F5.
- Safari. Press ⌘-Option-E.
- Sometimes bypassing the cache doesn't work, but purging it does. As discussed at the Wikipedia:Purge, page, follow this procedure: Click the "edit this page" tab. In your browser's address bar, at the end of the URL, where you see &action=edit, replace edit with purge, so it reads &action=purge. Then press Enter to tell your browser to go to that revised URL.
- Finally, if you're using Firefox 2 as your browser, you can use its browser console to track down errors one by one. Go to Tools→Error Console. You'll probably see a lot of warnings, but you want to see errors, so click the red stop sign icon, the one with Errors next to it.
- The next page lists any scripts with problems. Clicking an entry in the list takes you to the page with the code on it, with the error highlighted. Now recheck the source of the code (that's why you put comments in the code about where you got it). If you didn't make a mistake in copying, then you probably want to comment out the script (by placing double slash marks at the beginning of each line) if it's interfering with other scripts. Then either post a talk page note for whoever created the script, or a note at the Village Pump technical page (WP:VPT). (The second choice is better if you think the script is a popular one.)
User scripts are scattered throughout Wikipedia. You may find one just because someone mentioned it, or because you came across it in the index (shortcut: WP:EIW). The largest collection of scripts (or links to scripts) is at Wikipedia:WikiProject User scripts/Scripts (shortcut: WP:JS). Other places to check are: