User talk:Majora/LicenseReview.js

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

To install, put the following line into your common.js:

importScript('User:Majora/LicenseReview.js');

License review tab[edit]

The license review tab for media has disappeared on my end. It doesn't show up while I'm on the file's description page, its history tab, or editing the page—the latter two would were guarantees in instances where the first wasn't visible. I'm wondering if this is an issue related to the script? xplicit 08:35, 28 August 2018 (UTC)[reply]

@Explicit: It is not showing up at all? That's...odd. It is working fine for me. When did this start? I hope that is not linked to the new security measures with .js scripts that the WMF did. Did you try bypassing your cache (ctrl + F5)? See if that reloads the script. If that doesn't work right-click and click inspect and then on the Console tab. Then reload the page to rerun the script. Let me know if any errors popup. --Majora (talk) 21:18, 28 August 2018 (UTC)[reply]
I'd say it started about a week ago. The above remedies did not resolve the issue. xplicit 06:02, 29 August 2018 (UTC)[reply]
Was there any error messages in the console, Explicit. What browser are you using? Can you try a different one? The switch over for .js pages happened on the 27th so if it started a week ago it is something else. --Majora (talk) 20:45, 29 August 2018 (UTC)[reply]
I'm using the latest version of Firefox. I checked on Google Chrome, and the tab doesn't appear there, either. There are two errors that appeared on the console:
Extended content

TypeError: mw.util is undefined[Learn More] File:180717_열린음악회_트와이스_01.jpg:1:42 <anonymous> https://commons.wikimedia.org/wiki/File:180717_열린음악회_트와이스_01.jpg:1:42 domEval https://commons.wikimedia.org/w/load.php:92:213 runScript https://commons.wikimedia.org/w/load.php:94:20 enqueue https://commons.wikimedia.org/w/load.php:92:378 checkCssHandles https://commons.wikimedia.org/w/load.php:94:621 execute https://commons.wikimedia.org/w/load.php:95:384 handlePending https://commons.wikimedia.org/w/load.php:89:699 markModuleReady https://commons.wikimedia.org/w/load.php:93:561 runScript https://commons.wikimedia.org/w/load.php:94:36 checkCssHandles https://commons.wikimedia.org/w/load.php:94:670 execute https://commons.wikimedia.org/w/load.php:95:384 handlePending https://commons.wikimedia.org/w/load.php:89:699 markModuleReady https://commons.wikimedia.org/w/load.php:93:561 runScript https://commons.wikimedia.org/w/load.php:93:960 checkCssHandles https://commons.wikimedia.org/w/load.php:94:670 execute https://commons.wikimedia.org/w/load.php:95:384 implement https://commons.wikimedia.org/w/load.php:101:148 <anonymous> https://commons.wikimedia.org/w/load.php:474:1159

and

ReferenceError: addPortletLink is not defined[Learn More] index.php:39:2 twinkleunlink https://commons.wikimedia.org/w/index.php:39:2 <anonymous> https://commons.wikimedia.org/w/load.php:474:1686 mightThrow https://commons.wikimedia.org/w/load.php:211:590 resolve/</process< https://commons.wikimedia.org/w/load.php:212:269

xplicit 01:13, 30 August 2018 (UTC)[reply]

I think I figured it out, Explicit. You should have received a message on your talk page regarding VFC installation back in 2017. See User talk:Majora/Archive 1#Your VFC installation method is deprecated. VFC should not be directly installed like that in your .js file. Remove that line and try again. You can "install" VFC directly from your gadget tab in your preferences. --Majora (talk) 01:53, 30 August 2018 (UTC)[reply]
Success! Very much appreciated, Majora. A scan of my archive shows that I did not receive this message you mentioned. Now I can return to reviewing files. xplicit 02:39, 30 August 2018 (UTC)[reply]
Great news! Strange that you didn't receive that message. They must have missed you. Also strange that it took over a year for the deprecated code to cause problems. They must have finally removed backwards compatibility. Good to know for the future in case this happens again. --Majora (talk) 02:43, 30 August 2018 (UTC)[reply]

getSource[edit]

Hi, please add \s* before Source, so that it can find the url given at the source parameter of toollabs:url2commons uplaods such as File:Hanieh Tavassoli 20180209 05.jpg.

var getSource = function(val) {
	var ret, r = val.match(/\|\s*Source\s*=(.+)/i);
	if (r && r[1]) {
		ret = $.trim(r[1]);
	}
	if (!ret) {
		r = val.match(/http:\/\/photozou.jp[^\s\]\|]+/i);
		if (r) {
			ret = r[0];
		}
	}
	return ((ret || 'http://'));
};

Thanks 4nn1l2 (talk) 12:33, 16 January 2019 (UTC)[reply]

@4nn1l2: ✓ Done --Majora (talk) 21:27, 16 January 2019 (UTC)[reply]

remove ! when prompt for source[edit]

I suggest when the script promptForSource, it should check for {{!}}, remove it or replace it with -, because of Template_talk:LicenseReview#malformation_due_to_template:!.--Roy17 (talk) 02:29, 9 February 2019 (UTC)[reply]

Roy17 Do we want "-" or what Perhelion recommended ("|")? Both shouldn't be hard to implement I just need to know which way we want to go here. --Majora (talk) 17:51, 9 February 2019 (UTC)[reply]
That was my personal suggestion, because I don't think adding a whole chunk of "<nowiki>|</nowiki>" is that important. Removing it or replacing it with a dash is similar to how : in file names is handled. I think it's at you the script designer's discretion to provide this minor workaround even without consensus.--Roy17 (talk) 18:05, 9 February 2019 (UTC)[reply]
Mkay. I'm just very averse to rocking any boats. I'll go ahead and make the changes though. --Majora (talk) 18:15, 9 February 2019 (UTC)[reply]
I just tested | and it worked. I think character entity references are better than the nowiki method.--Roy17 (talk) 18:25, 9 February 2019 (UTC)[reply]
@Roy17: I made it so that it changes the source link as well. Quickest way to fix it. Perhelion is right, {{!}} is a special use case and it really shouldn't be used in plain text like this anyways. --Majora (talk) 19:18, 9 February 2019 (UTC)[reply]

error in locating the empty template[edit]

special:diff/339997969, the script failed to identify the string "{{LicenseReview |site= |user= |date= }}".--Roy17 (talk) 14:26, 21 February 2019 (UTC)[reply]

If you fixed it, File:ALS animal models, photos only.jpg and File:ALS animal models.jpg could be used to test it. :) --Roy17 (talk) 14:33, 21 February 2019 (UTC)[reply]
✓ Done @Roy17: . Please watch license numbers though. Those were CC-BY 4.0. Not 3.0. --Majora (talk) 21:43, 21 February 2019 (UTC)[reply]
Whoops. My mistake on the license version. Sorry bout that. --Majora (talk) 21:53, 21 February 2019 (UTC)[reply]
@Majora: Sorry it's me again. The fix yesterday probably causes another problem: special:diff/340142295 (when the lrw appears before a licence in the same line).--Roy17 (talk) 19:02, 22 February 2019 (UTC)[reply]
I have an ugly fix: /\{\{[Ll]icen[cs]e ?[Rr]eview ?(\|.*= ?)*\}\}/ :) --Roy17 (talk) 19:20, 22 February 2019 (UTC)[reply]
All set, Roy17. Thank you. I never actually thought of the possibility that the license could be on the same line (obviously). Hence .* for the replacement. That's what I get for doing quick fixes instead of thinking stuff all the way through. --Majora (talk) 21:20, 22 February 2019 (UTC)[reply]
Thanks a lot! I confirm it's working for both cases now: special:diff/340154264 special:diff/340153516.--Roy17 (talk) 21:36, 22 February 2019 (UTC)[reply]

Insert before categories[edit]

I have a suggestion. Is it possible to tweak the script so that it would insert the full template before the first line of [[Category: (for cases like special:diff/340031897)?--Roy17 (talk) 19:38, 21 February 2019 (UTC)[reply]

Probably. This one will just take longer to implement. I'll get to it when I have time. --Majora (talk) 21:44, 21 February 2019 (UTC)[reply]

Hi, could you please history-merge User:Rillke/LicenseReview.js into your script and replace the remaining redirect with

// this script is no longer maintained
// please update your installation with
importScript('User:Majora/LicenseReview.js');

Thanks! Rillke(q?) -- 16:24, 27 July 2019 (UTC)[reply]

Maybe you want to make your script a gadget anyway? Gadgets are much easier to maintain, to activate by users; and they do not "belong" to someone and they allow using ressource loader. -- Rillke(q?) 16:27, 27 July 2019 (UTC)[reply]
Only interface admins can mess with gadgets just like only interface admins can mess with other's .js scrips. I cannot edit User:Rillke/LicenseReview.js at all. If we really wanted a complete history we should go all the way back to ZooFari's version. I'm not entirely sure that is necessary to merge all of that. --Majora (talk) 03:04, 29 July 2019 (UTC)[reply]
Proper notification as I forgot to sign the first time: @Rillke: --Majora (talk) 03:04, 29 July 2019 (UTC)[reply]
According to Commons:Interface administrators, you may just go to Commons:Bureaucrats' noticeboard and request temporary IA-ship. I gave up on the script while ZooFari's version is still listed in welcome templates and the like; and AFAIK duplicating history entries is not possible, so maybe merge that later. I just want to get entirely rid of the script, that's why I asked. -- Rillke(q?) 07:02, 29 July 2019 (UTC)[reply]

Loading forever for some files[edit]

such as File:Julie Zhuo works at Facebook.png and File:Julie Zhuo at Facebook.png. Your script is working for other files, so I assume there's something wrong with these files that make the script load forever.--Roy17 (talk) 01:47, 12 August 2019 (UTC)[reply]

This appears to have fixed itself (?) at least on my end. I reviewed the files and it worked quite quickly. --Majora (talk) 21:22, 28 August 2019 (UTC)[reply]
Well, I just tried. They are still loading forever. I'm using Firefox, Windows 10. Very weird bug... I guess somehow this browser is not working with your script for these two files.--Roy17 (talk) 21:43, 28 August 2019 (UTC)[reply]
If you open the console (instructions) are you seeing any errors? Warnings are fine, and are pretty common, but errors mean something is awry. I use chrome on 10 and it appeared to be working fine for me. --Majora (talk) 21:51, 28 August 2019 (UTC)[reply]
I compared the first one with another file that's working. Aha it has one extra warning that says Loading failed for the <script> with source “https://commons.wikimedia.org/w/api.php?format=json&callback=HotCat.start&action=query&rawcontinue=&titles=File%3AJulie_Zhuo_works_at_Facebook.png&prop=info%7Crevisions&rvprop=content%7Ctimestamp%7Cids&meta=siteinfo&rvlimit=1&rvstartid=363642802”. File:Julie_Zhuo_works_at_Facebook.png:1:1 .--Roy17 (talk) 22:16, 28 August 2019 (UTC)[reply]
So...I'm gonna need more info since this appears to only be happening on your end. Can you follow the instructions at mw:Help:Locating broken scripts#Identify the problems? You'll have to open the console again and then go to https://commons.wikimedia.org/wiki/File:Julie_Zhuo_works_at_Facebook.png?debug=true. Debug will clear out all those warnings and should only display problematic things. Specifically it will tell you where the error is occurring on the right hand side. That should give me more info on where to start looking. Also, please know, I may not be able to fix anything since it is hard to troubleshoot what I can't directly see. --Majora (talk) 23:13, 28 August 2019 (UTC)[reply]
Sorry I dont have much time to investigate this and if I do I'll try to DIY first. You might shelve this issue.--Roy17 (talk) 23:21, 27 January 2020 (UTC)[reply]

Is it possible to make the pop-up input window wider and larger?[edit]

so that it's easier to edit the source string automatically fetched?--Roy17 (talk) 13:34, 14 August 2019 (UTC)[reply]

@Roy17: That prompt is created and displayed by your browser. Not by the script. The current way the script is written making it larger is, unfortunately, not possible. To make it modifiable, I would have to redo it so it is a popup much like the "would you like to thank the person on flickr" popup. Certainly a possibility but not quite sure if I want to fiddle around that much if it isn't impacting a large amount of instances. --Majora (talk) 21:21, 28 August 2019 (UTC)[reply]

Remove review needed categories automatically[edit]

Currently, the script removes Category:Tasnimnews review needed upon review automatically. Please make the following change in order to cover the review categories of other Iranian news agencies listed below:

/\[\[Category:Tasnimnews review needed\]\]/g

to

/\[\[Category:((Tasnim|Moj|Fars|Mehr|Nasim)news|SNN|Khamenei\.ir) review needed\]\]/g

Thank you. 4nn1l2 (talk) 15:26, 27 August 2019 (UTC)[reply]

✓ Done --Majora (talk) 21:19, 28 August 2019 (UTC)[reply]

Automatically removing Category:CSS.ir review needed[edit]

Hello. First of all, thank you for this great scripts.

I've recently created Category:CSS.ir review needed, used mainly in {{Center for Strategic Studies/subst}}. We need a slight change in the script in order to automatically remove this category when reviewing the license.

tb1.value = tb1.value.replace(/\[\[Category:((Tasnim|Moj|Fars|Mehr|Nasim)news|SNN|Khamenei\.ir) review needed\]\]/g, '');

to

tb1.value = tb1.value.replace(/\[\[Category:((Tasnim|Moj|Fars|Mehr|Nasim)news|SNN|CSS|Khamenei\.ir) review needed\]\]/g, '');

Thank you. Ahmadtalk 19:42, 25 October 2019 (UTC)[reply]

✓ Done --Majora (talk) 20:18, 25 October 2019 (UTC)[reply]

Still working?[edit]

Hi. After Special:Diff/372477664 by Krinkle, I can't see the script anymore. Checked the console, no errors. I use Google Chrome. Not sure if it's just me or not. Is there anyone else experiencing the same issue? Thank you. Ahmadtalk 20:39, 30 October 2019 (UTC)[reply]

I think that the diff linked is wrong --DannyS712 (talk) 21:17, 30 October 2019 (UTC)[reply]
Yeah, I believe they meant 372477664 (with an extra 4), which was the last revision to this page. --Krinkle 22:08, 30 October 2019 (UTC)[reply]

@Ahmad: I've reverted my edit as precaution. However, I don't see how this change could have caused a breakage to LicenseReview.js. Let me know if it works again now. --Krinkle 22:08, 30 October 2019 (UTC)[reply]

@Krinkle: Appears to be a problem with $changeHref according to the error console. Doesn't appear to have anything to do with your recent change as the Beta version (which was untouched) also had the same error. Has anything else been deprecated recently? I probably should follow these developments but I tend to forget. The exact error is:
ReferenceError: $changeHref is not defined
    at Object.installLLinks (index.php?title=User:Majora/LicenseReview.js&action=raw&ctype=text/javascript:598)
    at index.php?title=User:Majora/LicenseReview.js&action=raw&ctype=text/javascript:792
    at fire (load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets|jquery.ui|mw.config.values.wbSiteDetails|wikibase.tainted-ref|wikibase.view.ControllerViewFactory&skin=vector&version=134wp:45)
    at Object.fireWith [as resolveWith] (load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets|jquery.ui|mw.config.values.wbSiteDetails|wikibase.tainted-ref|wikibase.view.ControllerViewFactory&skin=vector&version=134wp:47)
    at Object.deferred.<computed> [as resolve] (load.php?lang=en&modules=jquery%2Coojs-ui-core%2Coojs-ui-widgets|jquery.ui|mw.config.values.wbSiteDetails|wikibase.tainted-ref|wikibase.view.ControllerViewFactory&skin=vector&version=134wp:50)
    at Object.ready (<anonymous>:5:834)
    at doPropagation (load.php?lang=en&modules=startup&only=scripts&raw=1&skin=vector:8)
--Majora (talk) 22:19, 30 October 2019 (UTC)[reply]
@Krinkle: Weird, but doesn't work even after the revert (I used it at 17:28, 30 October here). I also tried using a different browser, no luck. Not sure if anyone else is experiencing this problem as well. Ahmadtalk 08:07, 31 October 2019 (UTC)[reply]
ReferenceError: "assignment to undeclared variable $changeHref" is pretty much the hint to the solution. $changeHref is never defined (e.g. using var $changeHref) and the code is supposed to run in strict mode. -- Rillke(q?) 16:53, 31 October 2019 (UTC)[reply]
Special:Diff/370498850 most likely broke it if this is important. However, I suggest you keep the change and declare that one undeclared variable. -- Rillke(q?) 17:06, 31 October 2019 (UTC)[reply]
			$failHref.click(function (e) {
				e.preventDefault();
				execEdit(licenseReviewer.LicenseReview_F);
			});
-			var $lrNode = $('div.LR');
+			var $changeHref,
+				$lrNode = $('div.LR');
			if ($lrNode.length) {
				$lrNode.css('text-align', 'center');
				$changeHref = $('<a>', {
					href: '#', text: 'change license'
				});
-- Rillke(q?) 17:27, 31 October 2019 (UTC)[reply]
@Rillke: Thank you for that. I don't really have time to fiddle with this right now but the change doesn't fix it completely. It reestablishes the buttons but doesn't pick up the approve/disapprove parts of the script. So all it shows is [change license] [] []. I'm not going to be able to really look at this until much later tonight or until the weekend but I wanted to let you, and other people coming here to tell me that the script is broken, that I will look into it as soon as I can. --Majora (talk) 20:43, 31 October 2019 (UTC)[reply]
How does it look in Monobook Skin? It's most likely MediaWiki_talk:Gadget-editDropdown.js#Broken. -- Rillke(q?) 10:52, 1 November 2019 (UTC)[reply]
Works in Monobook: Special:Diff/372816279. Ahmadtalk 12:11, 1 November 2019 (UTC)[reply]
Indeed. I can also confirm that it works on my browser as well. I'll try to get an interface admin to perform the changes required. --Majora (talk) 16:21, 1 November 2019 (UTC)[reply]

@Ahmad252, DannyS712, Krinkle, and Rillke: This appears to be working now. Thank you ‎Zhuyifei1999 for making the necessary fix on the MediaWiki page. It is appreciated. If there are additional problems please let me know. --Majora (talk) 20:21, 1 November 2019 (UTC)[reply]

Thanks. Works properly now. Ahmadtalk 20:43, 1 November 2019 (UTC)[reply]

Link to reviewer[edit]

When reviewing {{GODL-India}} files it adds |reviewer=Reviewer's username, it would be more useful if it's |reviewer=User:Reviewers name. -- CptViraj (📧) 06:14, 12 January 2020 (UTC)[reply]

@CptViraj: Should be ✓ Done. Let me know if you have any issues. --Majora (talk) 12:34, 14 January 2020 (UTC)[reply]
@Majora: See Special:Diff/387350692, should be [[User:Reviewer|Reviewer]]. -- CptViraj (📧) 12:52, 14 January 2020 (UTC)[reply]
@CptViraj: I changed it to be ~~~ which should produce both the user and user talk page link instead. If you really want it to only be the username I can change it back but the I thought the talk link might be useful if someone needs to contact you due to a review you performed. --Majora (talk) 12:43, 15 January 2020 (UTC)[reply]
No problem, Thankyou! -- CptViraj (📧) 16:07, 15 January 2020 (UTC)[reply]

Extra pipe appeared for youtube[edit]

Script inserted an extra pipe special:diff/390160650. Sorry I glanced through your latest commit but couldnt spot how to debug.--Roy17 (talk) 23:21, 27 January 2020 (UTC)[reply]

@Roy17: Good catch. I didn't even notice that when I was testing. The youtubeparams variable includes that pipe so it doesn't need to have it again. Since || doesn't do anything it never affected the rendering so I missed it. Should be all fixed. --Majora (talk) 02:34, 28 January 2020 (UTC)[reply]

MediaWiki:LicenseReview.js[edit]

Hello.

Unfortunately Majora, the last maintainer of the script, just left the Wikimedia projects. Please update your your common.js to the following:

importScript('MediaWiki:LicenseReview.js');

4nn1l2 (talk) 14:12, 29 March 2020 (UTC)[reply]

@4nn1l2: I believe it'll be more efficient for an interface admin to do it as this page (also Commons:License review) might not be on the watchlist of some users. Minoraxtalk (formerly 大诺史) 14:38, 29 March 2020 (UTC)[reply]
@Minorax: You are right that its will be more efficient, but as an interface admin myself, I prefer not to edit userpages of other users unless absolutely necessary. The "old" script still works and there is no rush (no urgent matter). I will leave a message at VP which is viewed by more users. At the moment 106 users have the "Majora/LicenseReview.js" on other common.js. Let's wait and see how many users will notice my message. 4nn1l2 (talk) 14:54, 29 March 2020 (UTC)[reply]
@4nn1l2: Hmm. Works as well. Minoraxtalk (formerly 大诺史) 15:09, 29 March 2020 (UTC)[reply]