Admin Forum:WantedFiles issue

I'm having an issue with Special:WantedFiles at Gran Turismo Wiki. Whenever I click a red-link in the Wanted Files list, I am sent to an edit page, rather than an upload page. Can I change some settings to fix this?

Thanks

MTracey1 PSN/XBL: Mackem1985 23:54, March 5, 2012 (UTC)


 * I don't think there is a setting to fix this lameness, but you can make some Javascript to fix it. When I get more time I'll post some JS to remove the &action=edit from the redlink which should make it do what you want. -- Fandyllic (talk &middot; contr) 6 Mar 2012 2:32 PM Pacific


 * Okay, I tested this here on Community at User:Fandyllic/wikia.js and it seems to work. It basically changes the link into an upload link.

 function ImgDescEditLink2Upload { $('ol.special > li > a.new').each(function {   this.setAttribute("href", this.getAttribute("href").replace(/\&action\=edit\&redlink\=1/, ""));    this.setAttribute("href", this.getAttribute("href").replace(/File:/, "Special:Upload&wpDestFile="));  }); } addOnloadHook(ImgDescEditLink2Upload);
 * As with all my JS code, I have to give a standard disclaimer: I'm not the best coder, so it is probably not the most efficient way to do this and it may have unintended consequences, since testing was minimal. I think it will only affect links of this sort on Special:WantedFiles, but it might work too globally. -- Fandyllic (talk &middot; contr) 6 Mar 2012 4:05 PM Pacific


 * Here's a simplified version of the above that just removes &action=edit:

 function ImgDescEditLink2ImgLink { $('ol.special > li > a.new').each(function {   this.setAttribute("href", this.getAttribute("href").replace(/\&action\=edit/, ""));  }); } addOnloadHook(ImgDescEditLink2ImgLink);
 * -- Fandyllic (talk &middot; contr) 6 Mar 2012 4:26 PM Pacific


 * Thanks. I assume if I put this into User:MTracey1/wikia.js it will only affect my editing, but if I add it to MediaWiki/Common.js (which I don't intend to) it would affect everyone?  Please excuse my lack of knowledge on the subject - I know my WikiMarkup pretty well, but js gives me a headache.
 * MTracey1 PSN/XBL: Mackem1985 01:58, March 7, 2012 (UTC)

This is more along the speed of what you are wanting. This takes all red linked files on Special:WantedFiles and changes them into a Special:Upload link with the correct filename. This will only affect red linked files on this page and only within the list. You can place this in Special:MyPage/global.js to work on all wikis that you view this special page on or in Special:MyPage/common.js on the specific wiki of choice.

Working example here. Let me know if you notice any issues. Rappy 05:31, March 7, 2012 (UTC)
 * I've added that code to User:MTracey1/common.js and to User:MTracey1/global.js and I'm not seeing any difference. I can see why it should work (although I'm certainly no expert), but it isn't. I don't understand what I'm doing wrong.
 * MTracey1 PSN/XBL: Mackem1985 05:48, March 7, 2012 (UTC)


 * Global.js would have been for here on Central. As for Gran Turismo Wiki, apparently, common.js does not work for both skins. If you're using Oasis, place the code in Wikia.js. For Monobook, place it in Monobook js. Rappy 05:58, March 7, 2012 (UTC)


 * Did you manage to get that to work on gt-wiki? I'm still having trouble with it.  If so, maybe it's a JavaScript problem on my computer.  Either way, it's about time I got some sleep, so I'll get back to this tomorrow.  It's not imperative that I get this working, but it would be helpful.
 * Thanks
 * MTracey1 PSN/XBL: Mackem1985 06:14, March 7, 2012 (UTC)


 * Yes, it is working for me. It could be a cache issue on your end. It should show for you by tomorrow. Rappy 06:15, March 7, 2012 (UTC)

Logged in this afternoon and it's working perfectly! Thanks for your help. MTracey1 PSN/XBL: Mackem1985 16:48, March 7, 2012 (UTC)


 * Hi Rappy! There's a little bug in your JS: In the second line you use an assignment instead of a comparison.


 * Apart from that detail, I'm totally stealing your idea:


 * Pecoes 00:29, March 8, 2012 (UTC)


 * Can someone add this to Dev wiki? -- Fandyllic (talk &middot; contr) 7 Mar 2012 7:01 PM Pacific


 * Sure. I can do that. I'll file it under "Fix for Special:WantedFiles" and credit you and Rappy. Alright? -- Pecoes 04:10, March 8, 2012 (UTC)

Okay. It's been added to the dev wiki. I decided against using a importScriptPage, though. It's a little too short for that IMHO.

Here's the latest version:

Pecoes 05:24, March 8, 2012 (UTC)