添加Cloudflare网络分析功能 |
小无编辑摘要 |
||
(未显示同一用户的1个中间版本) | |||
第7行: | 第7行: | ||
document.head.appendChild(script); | document.head.appendChild(script); | ||
// End Cloudflare Web Analytics | // End Cloudflare Web Analytics | ||
$(function () { | |||
// 只在 Special:Search 页面且没有结果时运行 | |||
if (mw.config.get("wgCanonicalSpecialPageName") === "Search" && | |||
$(".mw-search-nonefound").length) { | |||
const searchTerm = mw.util.getParamValue("search"); | |||
const googleUrl = "https://www.google.com/search?q=" + encodeURIComponent(searchTerm); | |||
$("<p>").html(`或者到 <a href="${googleUrl}" target="_blank">Google 中搜索“${searchTerm}”</a>。`) | |||
.insertAfter(".mw-search-nonefound"); | |||
} | |||
}); |
2025年5月8日 (四) 09:11的最新版本
/* 这里的任何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" &&
$(".mw-search-nonefound").length) {
const searchTerm = mw.util.getParamValue("search");
const googleUrl = "https://www.google.com/search?q=" + encodeURIComponent(searchTerm);
$("<p>").html(`或者到 <a href="${googleUrl}" target="_blank">Google 中搜索“${searchTerm}”</a>。`)
.insertAfter(".mw-search-nonefound");
}
});