WikiQueer:Scripts


 * This is about general scripts. For user scripts, see WikiQueer:WikiProject User scripts. For Greasemonkey user scripts see WikiQueer:Tools/Greasemonkey user scripts. For other tools, see WikiQueer:Tools

This page serves as a central repository for scripts and scripting requests on WikiQueer. Please feel free to improve any of these scripts but make sure to test your changes first. Like the rest of WikiQueer, all material here is under CC-By-SA 3.0. See licensing for further details.

KISS
Remember to Keep it Simple, Stupid. Do one thing and do it well; this is a place for simple scripts and not whole programs.

License
All material on WikiQueer is by default under the WQ:CC-BY-SA license (and in most cases, also the GNU Free Documentation License (GFDL)). The CC-BY-SA license is designed for artistic and literary works but not for software. If you want your work to be of the greatest use to the public, please consider dual-licensing it and releasing it under a free software license such as the GNU General Public License (GPL) in addition to the other license(s). Like the GFDL, the GPL is released by the Free Software Foundation. You can use both by explicitly stating in a comment at the start of your script that your script is dual-licensed under the GPL.

Perl
A HTML character entity converter written in Perl that uses the ord function to convert a character to its corresponding number in the character set. It operates on standard input.

AppleScript
Author: Olof

Notes: I got fed up with looking up Unicode characters, so I wrote an AppleScript for my favorite styled text editor (Style) to write them for me. Now, I can just type Japanese into a text edit window like this

&#23567; &#27849; &#32020; &#19968; &#37070;

select it, choose my script from the scripts menu, and it turns into

&#23567; &#27849; &#32020; &#19968; &#37070; &amp;#23567; &amp;#27849; &amp;#32020; &amp;#19968; &amp;#37070;

Which is what you can paste into the WikiQueer edit window. I'm using a Mac, so this is a mac only solution, but I thought I'd share it for those of you who can use it. Here's the script:

compile this in ScriptEditor, and save it in the "Style Scripts folder in the same folder where the Style application lives. I have mine saved as "Append Unicoded HTML".  Thereafter it will appear in   Style's Scripts menu.

Style is available at merzwaren ($20 shareware). I have this running on Mac OS X 10.2.1 with Style version 1.9.2

set theHTML to "" tell application "Style" set selText to selection of document 1 as Unicode text set selStart to get offset of selection of document 1 set selEnd to get offset of end of selection of document 1 set dataLen to (selEnd - selStart) end tell set tempName to "unicode temp"

tell application "Finder" if alias tempName exists then move alias tempName to the trash end if end tell

set fileRef to open for access tempName with write permission write selText to fileRef set myRawData to read fileRef from 0 for dataLen close access fileRef

tell application "Finder" move alias tempName to the trash end tell

set numChars to dataLen div 2 repeat with n from 1 to numChars set theHTML to theHTML & "&#" set a to get character (2 * n - 1) of myRawData set b to get character (2 * n) of myRawData set lVal to ((ASCII number b) + (256 * (ASCII number a))) set theHTML to (theHTML & lVal as string) & "; " end repeat

tell application "Style" set selection of document 1 to ((selection of document 1) & " ( " & theHTML & " ) ") end tell

JavaScript
Authors:
 * &#1603;&#1587;&#1610;&#1662; Cyp 10:14 7 Jun 2003 (UTC) ( initial write )
 * --Ævar Arnfjörð Bjarmason 16:02, 2004 May 16 (UTC) ( major cleanup of html code, added indenting )

Known to work on:
 * Internet Explorer 5.00.3502.1000
 * Mozilla Firefox 0.8

Notes:

You may not need a script for converting CJK characters if you have a Mac running Mac OS X 10.2 and have Mozilla as your browser. Just do the editing from within Mozilla. Mozilla automatically does the conversion. For example, in adding this edit, I type in the Japanese characters for "edit," which are &#32232;&#38598;. Mozilla automatically converted these characters to the proper romanized Unicode format. Just look at the above lines in the editing box to see for yourself. -Wikipedia:User: IppikiOokami 5 September 2003

Watchlist and undeletion select-all script
This script usefully checks all checkboxes on a WikiQueer page, useful for clearing large watchlists or restoring pages with large histories. It works in Firefox Internet Explorer, Camino and Safari.

In Firefox, create a bookmark, with the following code in the "location" field. In Internet Explorer, create a favourite, and once it's created, right click it, select "properties" and place the following code in the "URL" box (it will give you an invalid protocol warning, but you can ignore this, and it will work).

In Safari, use the "Show all Bookmarks" option. Choose the "Bookmarks Bar" collection. Select the script below into the copy buffer and simply paste ([Command]-v) it into the window on the right. A new bookmark will automatically be created and will appear in the bookmarks bar. Re-name it something sensible like "Select All".

 javascript:for (i=0; i

Upload script
A script written in Perl to mass upload photographs to Commons. See commons:User:Nichalp/Upload script.