User:Lower/common.js

来自Vocawiki
Lower留言 | 贡献2025年9月15日 (一) 19:10的版本 (// Edit via InPageEdit)
跳转到导航 跳转到搜索

注意:在发布之后,您可能需要清除浏览器缓存才能看到所作出的更改的影响。

  • Firefox或Safari:按住Shift的同时单击刷新,或按Ctrl-F5Ctrl-R(Mac为⌘-R
  • Google Chrome:Ctrl-Shift-R(Mac为⌘-Shift-R
  • Edge:按住Ctrl的同时单击刷新,或按Ctrl-F5
/**
  *mw.loader.load('https://mzh.moegirl.org.cn/index.php?title=User:Nzh21/js/QuickDiff.js&action=raw&ctype=text/javascript');
  */
$(function () { function d() { c && (c.abort(), c = null) } var a, b, c; $(document).on("mouseover", "a", function (e) { var f = this; /((Special|%E7%89%B9%E6%AE%8A):(Diff|%E5%B7%AE%E5%BC%82|%E5%B7%AE%E7%95%B0))|[?&]diff=/i.test(f.href) && !/#/.test(f.href) && (clearTimeout(b), clearTimeout(a), a = setTimeout(function () { var a, b, g; $("#quick-diff").length || ($("body").append('<div id="quick-diff"> <div id="quick-diff-close" onClick="$(\'#quick-diff\').hide();">x</div> <div id="quick-diff-arrow"></div> <div id="quick-diff-content"></div></div>'), $("head").append('<link rel="stylesheet" href="' + mw.config.get("wgLoadScript") + '?debug=false&modules=mediawiki.diff.styles&only=styles">'), $("head").append('<style type="text/css"> #quick-diff { border: 1px solid #a7d7f9; padding: 16px 24px 16px 24px; background-color: #ffffff; color: #222222; position: absolute; left: 20px; right: 20px; font-size: 14px; margin-bottom: 10px; display: none; z-index:20; } #quick-diff-close { cursor: pointer; position: absolute; top: 0px; right: 0px; margin: -2px 7px; font-size: 20px; } #quick-diff-content { max-height: 300px; overflow: auto; height: 100%; } #quick-diff-arrow { position:absolute; height:0px; width:0px; border:6px solid transparent; }</style>')), e.clientY < document.body.clientHeight / 2 ? ($("#quick-diff").css({ top: $(f).offset().top + $(f).height() + 6, transform: "" }).show(), $("#quick-diff-arrow").css({ top: "-13px", bottom: "", "border-top-color": "transparent", "border-bottom-color": "#a7d7f9", left: $(f).offset().left + $(f).width() / 2 - 20 - 6 })) : ($("#quick-diff").css({ top: $(f).offset().top - 6, transform: "translate(0, -100%)" }).show(), $("#quick-diff-arrow").css({ top: "", bottom: "-13px", "border-top-color": "#a7d7f9", "border-bottom-color": "transparent", left: $(f).offset().left + $(f).width() / 2 - 20 - 6 })), $("#quick-diff-content").html('<div style="text-align: center;">Loading...</div>'), a = (f.href.match(/[?&]oldid=(\d*)/i) || ["", null])[1], a || (a = (f.href.match(/(?:Special|%E7%89%B9%E6%AE%8A):(?:Diff|%E5%B7%AE%E5%BC%82|%E5%B7%AE%E7%95%B0)\/(\d+)\/\d+/i) || [null, null])[1]), b = (f.href.match(/[?&]diff=([^&]*)/i) || [null, null])[1], b || (b = (f.href.match(/(?:Special|%E7%89%B9%E6%AE%8A):(?:Diff|%E5%B7%AE%E5%BC%82|%E5%B7%AE%E7%95%B0)\/\d+\/(\d+)/i) || [null, null])[1], b || (b = (f.href.match(/(?:Special|%E7%89%B9%E6%AE%8A):(?:Diff|%E5%B7%AE%E5%BC%82|%E5%B7%AE%E7%95%B0)\/(\d+)/i) || [null, null])[1])), g = { action: "compare", format: "json", utf8: 1 }, jQuery.isNumeric(a) && jQuery.isNumeric(b) ? "0" == b ? (g.torelative = "cur", g.fromrev = a) : (g.fromrev = a, g.torev = b) : a ? (g.torelative = b, g.fromrev = a) : (g.torelative = "prev", g.fromrev = b), d(), c = $.ajax({ type: "GET", url: mw.config.get("wgScriptPath") + "/api.php", data: g, timeout: 15e3, success: function (a) { a.compare && null != a.compare["*"] ? ($("#quick-diff-content").html('<table class="diff diff-contentalign-left" data-mw="interface"><colgroup><col class="diff-marker"><col class="diff-content"><col class="diff-marker"><col class="diff-content"></colgroup><tbody>' + ("" === a.compare["*"] ? '<div style="text-align: center;">(没有差异)</div>' : a.compare["*"]) + "</tbody></table>"), $.each(window.QuickDiffExtension || [], function (b, c) { "function" == typeof c && c($("#quick-diff")[0], a) })) : $("#quick-diff-content").html('<div>出现未知错误,以下是错误信息,请<a href="/User_talk:Nzh21">反馈给Nzh21</a></div>' + JSON.stringify(a)), c = null }, error: function () { $("#quick-diff-content").html('<div style="text-align: center; color: red; font-size: larger;">网络连接出错</div>'), c = null } }) }, 300)) }), $(document).on("mouseout", function () { clearTimeout(a), clearTimeout(b), b = setTimeout(function () { d(), $("#quick-diff").hide() }, 500) }), $(document).on("mouseover", "#quick-diff", function () { clearTimeout(b) }), $(document).on("mouseout", "#quick-diff", function () { clearTimeout(b), b = setTimeout(function () { d(), $("#quick-diff").hide() }, 500) }) });


$.when(mw.loader.using(['mediawiki.api']), $.ready).then(function () {
    mw.loader.load('https://fastly.jsdelivr.net/npm/mediawiki-inpageedit');
    /** InPageEdit Preferences */
    ; (window.InPageEdit = window.InPageEdit || {}).myPreference = {
        "doNotCollectMyInfo": false,
        "editMinor": true,
        "editSummary": "$section // Edit via InPageEdit",
        "lockToolBox": true,
        "redLinkQuickEdit": false,
        "outSideClose": false,
        "watchList": "watch",
        "noConfirmEdit": false,
        "plugins": [
            "toolbox.js",
            "wiki-editor.js",
            "edit-any-page.js",
            "quick-thank.js"
        ]
    }
});


// 搜索中添加“编辑”和“历史”按钮
; (function () {
    if (mw.config.get("wgCanonicalSpecialPageName") !== "Search") return;
    $('.mw-search-result-heading a').each(function () {
        var href = $(this).attr('href');
        if (!href) return;
        var editLink = href.replace(href, href + '?action=edit');
        var hisLink = href.replace(href, href + '?action=history');
        var $edit = $('<a>', { href: editLink, class: 'search-edit', target: '_blank', text: '编辑' });
        var $his = $('<a>', { href: hisLink, class: 'search-his', target: '_blank', text: '历史' });
        $(this).after($('<span>', { class: 'extra-ipe-btn' }).append('&nbsp;&nbsp;(', $edit, ' | ', $his, ')'));
        mw.hook('InPageEdit').add(function (ctx) {
            ctx.InPageEdit.articleLink($edit);
        });
    });
})();

// 分类页面添加“编辑”和“历史”按钮
; (function () {
    if (mw.config.get("wgNamespaceNumber") !== 14) return;
    if (mw.config.get("wgArticleId") === 38120 || mw.config.get("wgArticleId") === 99958) return;
    $('.mw-category-generated .mw-content-ltr a').each(function () {
        var href = $(this).attr('href');
        if (!href) return;
        var editLink = href.replace(href, href + '?action=edit');
        var hisLink = href.replace(href, href + '?action=history');
        var $edit = $('<a>', { href: editLink, target: '_blank', text: '编辑' });
        var $his = $('<a>', { href: hisLink, target: '_blank', text: '历史' });
        $(this).after($('<span>', { class: 'extra-ipe-btn' }).append('&nbsp;&nbsp;(', $edit, ' | ', $his, ')'));
        mw.hook('InPageEdit').add(function (ctx) {
            ctx.InPageEdit.articleLink($edit);
        });
    });
})();

// Special:链接搜索添加“编辑”和“历史”按钮
; (function () {
    if (mw.config.get('wgPageName') !== 'Special:链接搜索') return;
    $('.special li a:nth-child(2)').each(function () {
        var href = $(this).attr('href');
        if (!href) return;
        var editLink = href.replace(href, href + '?action=edit');
        var hisLink = href.replace(href, href + '?action=history');
        var $edit = $('<a>', { href: editLink, target: '_blank', text: '编辑' });
        var $his = $('<a>', { href: hisLink, target: '_blank', text: '历史' });
        $(this).after($('<span>', { class: 'extra-ipe-btn' }).append('&nbsp;&nbsp;(', $edit, ' | ', $his, ')'));
        mw.hook('InPageEdit').add(function (ctx) {
            ctx.InPageEdit.articleLink($edit);
        });
    });
})();

mw.loader.load('https://vj-wiki.top/index.php?title=User:Lower/js/VocaDB-VOCALOID.js&action=raw&ctype=text/javascript');

mw.loader.load('https://vj-wiki.top/index.php?title=User:Lower/js/moesync.js&action=raw&ctype=text/javascript');