Commons talk:User scripts

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

Source code displayed by File:Javascript icon.svg[edit]

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)[reply]

Indeed, you are right :) the 2nd regexp will never match. -- RE rillke questions? 17:39, 1 September 2011 (UTC)[reply]
✓ Done -- RE rillke questions? 18:05, 1 September 2011 (UTC)[reply]
Das hast Du aber schön unter den Teppich gekehrt. -- RE rillke questions? 18:10, 1 September 2011 (UTC)[reply]
  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)[reply]
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)[reply]
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)[reply]

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)[reply]

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)[reply]
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)[reply]
You are welcome. Sadly, toolserver is down. -- Rillke(q?) 16:37, 23 September 2012 (UTC)[reply]
Think of a Script that would help cropping images directly from Commons (HTML5 Canvas + Ajax). WIP --Ricordisamoa 10:37, 17 February 2013 (UTC)[reply]
This was not possible at the time writing these lines as files reside on upload.wikimedia.org (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)[reply]
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)[reply]

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)[reply]

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)[reply]
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)[reply]

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)[reply]
@1: Technically only admins and gr can use supressredirect --Steinsplitter (talk) 22:17, 22 May 2014 (UTC)[reply]
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)[reply]
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)[reply]
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)[reply]
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)[reply]

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

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)[reply]

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)[reply]
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: https://bugs.launchpad.net/inkscape/+bug/171230 :( (the author told me).

 Not doneUser: Perhelion22:19, 7 July 2014 (UTC)[reply]

talk section[edit]

I really don't understand why is here a separate Commons:User scripts/talk page. Please keep it simple, can we merge this?User: Perhelion (Commons: = crap?)  10:13, 23 May 2015 (UTC)[reply]

Available scripts?[edit]

Where to find available scripts?--Juandev (talk) 11:39, 22 February 2017 (UTC)[reply]

@Juandev: see Category:User scripts ~nmaia d 00:09, 2 July 2019 (UTC)[reply]

Broken scripts and maintenance[edit]

Hello

Multiple users have reported broken scripts on Commons. You can see a list of issues on Phabricator.

Thos scripts are probably broken due to the use of depreciated JavaScript elements.

If by any change there is still a JavaScript guru who can have a look at them, I think the community will thank you a lot.

Thanks, Trizek (WMF) (talk) 14:10, 25 August 2017 (UTC)[reply]

Script request: adding language template for unspecified file descriptions.[edit]

There are countless examples of images with unspecified image descriptions (e.g. lacking {{En}} or {{Fr}})), especially those imported through Flickr2Commons. See for instance File:American Flag at half-mast, USS Blue Ridge (LCC-19) (39491231895).jpg. I've requested an option to specify language be added to Flickr2Commons, similar to the option on the Upload Wizard, and a user recommended developing a user script which adds the enveloping language template in one click. Regardless of whether it gets implemented in Flickr2Commons in the future, there is still the issue of what to do with exisiting unspecified languages. Could someone please develop a script that could do this in one or two clicks? I picture something like a drop down menu of languages, with the default being the user's preferred language or a language of their choosing (e.g. if I'm adding language templates to a lot of my own uploads, they'd be English, but if I was configuring a batch of files with Spanish descriptions, it'd be nice to default to Spanish for a while). Thanks for reading, -Animalparty (talk) 22:45, 24 February 2018 (UTC)[reply]

Hello Animalparty, I think this could be your choice User:MarkTraceur/editDescriptions.js. -- User: Perhelion 02:41, 25 February 2018 (UTC)[reply]

Filter category[edit]

Would it be possible to write a tool, which would provide filter options to highlight images from specific author and/or with a specific date within the category? Thx. Juandev (talk) 06:00, 14 April 2019 (UTC)[reply]

Dynamic pagination in Commons categories[edit]

X-posting from en:WP:USL#Categories.

I have started the development of a userscript I call mikiwedia. It is a bit different from other scripts in that it is version controlled in Git using GitHub. I am sharing this pattern in hopes of making collaborating and coding large, robust userscripts easier. It uses plain JavaScript and ES modules.

Specifically to Commons, it adds dynamic pagination capabilities to Category views. I.e., this makes it possible to view more than 200 files at a time, and also sort the images by their resolution. Hopefully, this can help with c:Category:Categories requiring diffusion and general category maintenance.

One caveat (as of today) is that it only works with the English localization, but it shouldn't be too difficult to make it work in a language-agnostic way.

The documentation (incl. installation steps) can be found here:

https://github.com/avindra/mikiwedia/wiki

Aavindraa (talk) 17:11, 1 August 2021 (UTC)[reply]

Lede[edit]

This has been at the top of this page since day one:

global acces aplication system main system pages files font attack : global system Android web view frequncy dayly event descripcion acces global aplication>>>>>[]{}<<<<<<

At first I thought it was recent vandalism, but so many experienced editors wave it though so many reverted bad edits I’m at a loss now. What’s this supposed to mean, typos and all? -- Tuválkin 07:54, 27 December 2022 (UTC)[reply]