User:PB2008/test.js

From Test Wiki
Revision as of 12:20, 25 March 2024 by PB2008 (talk | contribs) (Created page with "// References: MediaWiki:Gadget-rollback-summary.js from zhwp (https://zh.wikipedia.org/wiki/MediaWiki:Gadget-rollback-summary.js) // Reference2: MediaWiki:Revertpage from 52pokewiki (https://wiki.52poke.com/wiki/MediaWiki:Revertpage) (function rollbackSummary($, mw) { var batchConv = require('ext.gadget.HanAssist').batchConv; mw.messages.set(batchConv({ 'rollback-summary-custom': { hans: '已还原$1([[...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
// References: [[MediaWiki:Gadget-rollback-summary.js]] from zhwp (https://zh.wikipedia.org/wiki/MediaWiki:Gadget-rollback-summary.js)
// Reference2: [[MediaWiki:Revertpage]] from 52pokewiki (https://wiki.52poke.com/wiki/MediaWiki:Revertpage)
(function rollbackSummary($, mw) {
    var batchConv = require('ext.gadget.HanAssist').batchConv;

    mw.messages.set(batchConv({
        'rollback-summary-custom': {
            hans: '已还原[[Special:Contributions/$1|$1]]([[User talk:$1|对话]])的编辑:',
            hant: '已還原[[Special:Contributions/$1|$1]]([[User talk:$1|對話]])的編輯:'
        },
        'rollback-summary-nouser': { hans: '回退已隐藏用户的编辑:', hant: '回退已隱藏使用者的編輯:' },
        'rollback-summary-prompt': {
            hans: '请输入自定义回退摘要(留空则使用系统默认摘要)',
            hant: '請輸入自定義回退摘要(留空則使用系統預設摘要)'
        }
    }));

    var updateLinks = function updateLinks() {
        $('.mw-rollback-link a').off('click');
        $('.mw-rollback-link a')
            .on('click', function (e) {
                e.preventDefault();
                var href = this.href;
                var summary = prompt(mw.message('rollback-summary-prompt'));
                if (summary === null) {
                    return;
                } else if (summary === '') {
                    location.assign(href);
                } else {
                    var username = mw.util.getParamValue('from', href);
                    username
                        ? (summary = mw.message('rollback-summary-custom', username).plain() + summary)
                        : (summary = mw.message('rollback-summary-nouser').plain() + summary);
                    href += '&summary=' + encodeURIComponent(summary);
                    location.assign(href);
                }
            })
            .css('color', '#099');
    };
    mw.hook('wikipage.content').add(function () {
        updateLinks();
    });
})(jQuery, mw);