Commons talk:User scripts

From Wikimedia Commons, the free media repository
Jump to: navigation, search

Well, we could start by correcting the source code in this icon. My original was correct (though some people don't like adding functions to String.prototype). But then Perhelion's File:Nuvola apps important JS.svg got it wrong, and File:Toolbaricon source.svg also is wrong. Don't know if there are other derivatives. Lupo 17:31, 1 September 2011 (UTC)

Indeed, you are right :) the 2nd regexp will never match. -- RE rillke questions? 17:39, 1 September 2011 (UTC)
✓ Done -- RE rillke questions? 18:05, 1 September 2011 (UTC)
Das hast Du aber schön unter den Teppich gekehrt. -- RE rillke questions? 18:10, 1 September 2011 (UTC)
  1. Ich konnte mich gar nicht mehr erinnern, dass ich da zwei Versionen gelöscht hatte.
  2. Wenn ich die zwei gelöschten Versionen runterlade und anschaue, zeigen sie beide den richtigen Javascript-Code. Die erste Version 2008-03-14T08:36:00Z verwendete Text, der als schwarze Box dargestellt wurde. Die zweite Version von 08:38 Uhr wandelte den Text in Pfade um, damit die Anzeige klappte. Beide habe ich gelöscht, weil Inkscape in der SVG-Datei einen lokalen Dateipfad auf meinem Rechner abgelegt hatte, den ich aus Privacy-Gründen dort nicht haben wollte. Deshalb die dritte (heute einzige) Version, bei der ich diesen Dateipfad entfernt habe.
  3. Perhelion hat seine Version basierend auf der Version von 2008-03-26T14:10:43Z erstellt, und zwar am 19. Dez. 2010.
Was also meinst Du mit "unter den Teppich gekehrt"? Lupo 19:36, 1 September 2011 (UTC)
Na gut, war nur so eine Vermutung, auch wenn ich das nicht prüfen kann, will ich dir Glauben schenken. Gibt es diesbezüglich noch Unstimmigkeiten? -- RE rillke questions? 19:43, 1 September 2011 (UTC)
Nö, es hätte ja sein können, dass ich den Tippo auch schon 'mal drin hatte. War aber nicht. :-) Wenn Du das selbst überprüfen willst, musst Du wohl hier Admin werden. Danke für die Korrekturen! Lupo 19:51, 1 September 2011 (UTC)

Script request[edit]

Hello. I don't know if this is the right place to put this, but could anyone make a script that adds a link to quickly add {{crop}} to a file page? I'd like it to work like the "(request rotation)" button, and be put right next to it. Thanks, David1217 (talk) 15:36, 22 September 2012 (UTC)

If you look at Help:QuickDelete, you'll see how to add links to the toolbox that will prepend a template. In your case this could be:
window.AjaxDeleteExtraButtons = [
                    'label': 'Add {'+'{crop}}',
                    'tag': '{'+'{crop}}',
                    'img_summary': 'Suggesting to crop this media file.'
But instead of tagging it, you could operate Cropbot. Just create a TUSC account, add the proposed JavaScript link to your page and use the web-interface for cropping.
-- Rillke(q?) 21:48, 22 September 2012 (UTC)
Thank you Rillke! I've added your JavaScript to my common.js page. The Toolserver gave my a gateway timeout error when I tried to access it, though. David1217 (talk) 16:29, 23 September 2012 (UTC)
You are welcome. Sadly, toolserver is down. -- Rillke(q?) 16:37, 23 September 2012 (UTC)
Think of a Script that would help cropping images directly from Commons (HTML5 Canvas + Ajax). WIP --Ricordisamoa 10:37, 17 February 2013 (UTC)
This was not possible at the time writing these lines as files reside on (different domain). But now it should (they've added Access-Control-Allow-Origin * so the canvas isn't "dirty" after properly loading the pic into it). PNG only AFAIK (JPEG would be lossy and is not supported by some browsers for exporting the canvas content). And I can imagine that upload will be also difficult; In Firefox there is XHR.sendRaw() but not in other browsers. Sounds challenging. -- Rillke(q?) 14:25, 17 February 2013 (UTC)
Yes, one can now get all pixels from an image (for example, I'll implement this in FlagSense). And take a look at mw:API:Upload: sounds like we could use getImageData() and send the data directly to the server. --Ricordisamoa 14:50, 17 February 2013 (UTC)

Nice page[edit]

But who should find this page? For example there are links/redirects like this Commons:Userscripts to Commons:Tools but there is no mention to here!?!? So this page here is a secret? The only linked pages are Commons:Welcome and Commons:Gadget (very inconspicuous). Regards -- πϵρήλιο 13:34, 24 September 2012 (UTC)

No it isn't secret, feel free to change the redirect and link COM:TOOLS and this page. -- Rillke(q?) 15:17, 24 September 2012 (UTC)
Now I've done this[1][2][3]... (PS: I again don't found this page) Greetings -- Perhelion (talk) 15:56, 13 May 2014 (UTC)

Questions Move-Script[edit]

Hello, I've some questions about the move script:

  1. The useful option "keep a redirect" is not available for chose, I guess this only for admins?
  2. Why in hell subpages are not with moved??? I believe in Wikipedia there is a working Move-Script to do this, but here not?!? This page here is new (on my request) Commons:Rename a template but the solution is a bot request??? (For example some templates have dozens of subpages.) I really can't believe this issue. I hope here is someone and/or can give some information/suggestion. Thanks, best regards -- Perhelion 22:13, 22 May 2014 (UTC)
@1: Technically only admins and gr can use supressredirect --Steinsplitter (talk) 22:17, 22 May 2014 (UTC)
Ok yes, I see now Commons:File redirects (I tag them with speedy, if it are my own) Thanks. -- Perhelion 23:25, 22 May 2014 (UTC)
Moving subpages: The Move pages with their subpages (move-subpages) right is required. So just ask an admin. -- Rillke(q?) 07:58, 23 May 2014 (UTC)
Ok thanks, then I need to be an admin! (I put this information in the help page.) Regards! -- Perhelion 11:14, 23 May 2014 (UTC)
One more question, then this option is available for admins? PS. ok I see now on the ugly screenshots there is an option for admins. -- Perhelion 16:00, 23 May 2014 (UTC)

✓ Done -- Perhelion 17:03, 23 May 2014 (UTC)

Tool to extract/split a image sprite sheet[edit]

I searching for a script/tool to extract SVG. For pixel images I've simply done this with GIMP, but for SVG? I see Rillke has an SVG script maybe he knows somehow more. :) Here example sprites:[4][5] Greetings -- Perhelion 17:16, 30 May 2014 (UTC)

Use the source tab of your browser. Open the image you linked to in a modern, SVG supporting browser (e.g. Mozilla Firefox; disable Flash if it makes attempts to interfere), right click the element you want to extract, select inspect element, traverse up the DOM until you found the parent element containing only the one you want to copy, but the complete one, right click on the source of that node and "copy outer HTML". Too complicated? Simply use Inkscape? -- Rillke(q?) 19:35, 1 June 2014 (UTC)
It is a SVG sheet over 110 parts. I used after some trouble this script (it works for SVG export only with Inkscape dev beta) but unfortunately do another Inkscape bug this script can't export SVG right: :( (the author told me).

 Not done User: Perhelion22:19, 7 July 2014 (UTC)