Jump to content

User:Rezonansowy/js/ToCommons.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// Ported from [[pl:Wikipedysta:Żbiczek/zuo.js]], see there for authorship
if (wgCanonicalNamespace == 'Image' || wgCanonicalNamespace == 'File') {

    function do_it() {
        if (confirm('Mark file for transfer to commons?')) {
            var title = encodeURIComponent(mw.config.get('wgPageName'));
            window.location.href = "//en.wikipedia.org/w/index.php?action=edit&preload=User:Rezonansowy/mtc-nosubst&preloadtitle=Move to Commons&section=new&title=" + title;
        }
    }

    function nacommons_onload() {
        mw.util.addPortletLink('p-cactions', 'javascript:do_it(true)', "To commons!", 'nacommons-nazw', "Mark file for transfer to commons");
    }

    addOnloadHook(nacommons_onload);
}