Ztm0929留言 | 贡献
无编辑摘要
Ztm0929留言 | 贡献
无编辑摘要
第9行: 第9行:


$(function () {
$(function () {
     // 只在 Special:Search 页面且没有结果时运行
     // 只在 Special:Search 页面运行
     if (mw.config.get("wgCanonicalSpecialPageName") === "Search" &&
     if (mw.config.get("wgCanonicalSpecialPageName") === "Search") {
        $(".mw-search-nonefound").length) {
 
         const searchTerm = mw.util.getParamValue("search");
         const searchTerm = mw.util.getParamValue("search");
         const googleUrl = "https://www.google.com/search?q=" + encodeURIComponent(searchTerm);
         const googleUrl = "https://www.google.com/search?q=" + encodeURIComponent(searchTerm);


         $("<p>").html(`或者到 <a href="${googleUrl}" target="_blank">Google 中搜索“${searchTerm}”</a>。`)
         $("<p>").html(`你也可以到 <a href="${googleUrl}" target="_blank" rel="noopener">Google 中搜索“${searchTerm}”</a>。`)
             .insertAfter(".mw-search-nonefound");
             .insertAfter(".mw-search-results");
     }
     }
});
});

2025年5月9日 (五) 13:43的版本

/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
// Cloudflare Web Analytics
var script = document.createElement('script');
script.defer = true;
script.src = 'https://static.cloudflareinsights.com/beacon.min.js';
script.setAttribute('data-cf-beacon', '{"token": "6180aa28fe1943b48c4059a5056f4738"}');
document.head.appendChild(script);
// End Cloudflare Web Analytics

$(function () {
    // 只在 Special:Search 页面运行
    if (mw.config.get("wgCanonicalSpecialPageName") === "Search") {
        const searchTerm = mw.util.getParamValue("search");
        const googleUrl = "https://www.google.com/search?q=" + encodeURIComponent(searchTerm);

        $("<p>").html(`你也可以到 <a href="${googleUrl}" target="_blank" rel="noopener">Google 中搜索“${searchTerm}”</a>。`)
            .insertAfter(".mw-search-results");
    }
});