跳转到内容

User:Liangent/Gadgets/Copyvio/copyvio.js

维基百科,自由的百科全书

注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。

//<nowiki>
if (wgNamespaceNumber != -1) {
    jQuery(function() {
        addPortletLink(
            'p-cactions',
            'javascript:;',
            'cv',
            'ca-copyvio',
            'Mark as copyright violation'
        );
        
        jQuery('#ca-copyvio a').click(function() {
            var urlPromptMessage = 'URL (cancel = abort, leave blank + ok = finish):';
            var rawurl = prompt(urlPromptMessage);
            if (rawurl == null || rawurl == '') {
                return;
            }
            var url = '*' + rawurl;
            while (true) {
                rawurl = prompt(urlPromptMessage);
                if (rawurl == null) {
                    return;
                } else if (rawurl == '') {
                    break;
                } else {
                    url = url + '\n*' + rawurl;
                }
            }
            if (jQuery('#copyvio-message').length == 0) {
                jQuery('#jump-to-nav').after('<div id="copyvio-message"></div>');
            } else {
                jQuery('#copyvio-message').empty();
            }
            jQuery('#copyvio-message').append(
                '<div id="copyvio-marking">Adding Template:Copyvio ... <span id="copyvio-marking-status"></span></div>' + 
                '<div id="copyvio-vfd">Adding link on WP:CV ... <span id="copyvio-vfd-status"></span></div>' + 
                '<div id="copyvio-warning">Warning creator: <span id="copyvio-creator-username">' +
                '(Loading...)</span> ... <span id="copyvio-warning-status"></span></div>' + 
                '<div id="copyvio-patrolling">Patrolling ... <span id="copyvio-patrolling-status"></span></div>'
            );
            var page = new MediaWiki.Page();
            // {{copyvio}}
            page.text({text: '{\{subst:Copyvio/auto|url=' + url + '}}'},
                function() {jQuery('#copyvio-marking-status').text('Done');},
                function() {jQuery('#copyvio-marking-status').text('Failed');}
            );
            // vfd
            new MediaWiki.Page('Wikipedia:頁面存廢討論/疑似侵權').newSection(
                {text: '{\{subst:CopyvioVFDRecord|' + wgPageName + '}}'},
                function() {jQuery('#copyvio-vfd-status').text('Done');},
                function() {jQuery('#copyvio-vfd-status').text('Failed');}
            );
            // warning
            page.creator({}, function(username) {
                jQuery('#copyvio-creator-username').text(username);
                new MediaWiki.Page('User talk:' + username).newSection(
                    {text: '{\{subst:CopyvioNotice|' + wgPageName + '}}'},
                    function() {jQuery('#copyvio-warning-status').text('Done');},
                    function() {jQuery('#copyvio-warning-status').text('Failed');}
                );
            }, function() {
                jQuery('#copyvio-creator-username').text('(Failed)');
            });
            // patrol
            page.patrol({},
                function() {jQuery('#copyvio-patrolling-status').text('Done');},
                function() {jQuery('#copyvio-patrolling-status').text('Failed');}
            );
        });
    });
}
//</nowiki>