(创建页面,内容为“→这里的任何JavaScript将为所有用户在每次页面加载时加载。: $("a.mw-wiki-logo").attr("href", "https://wiki.knebulae.com"); $("a.mw-wiki-logo").attr("title", "访问首页");”) |
无编辑摘要 |
||
第1行: | 第1行: | ||
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | /* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */ | ||
function addCssFile(cssUrl) { | |||
var link = document.createElement("link"); | |||
link.rel = "stylesheet"; | |||
link.href = cssUrl; | |||
document.head.appendChild(link); | |||
} | |||
function addJsFile(jsUrl) { | |||
var script = document.createElement("script"); | |||
script.src = jsUrl; | |||
document.head.appendChild(script); | |||
} | |||
const pageScripts = { | |||
'首页': 'MediaWiki:Mainpage.js' | |||
}; | |||
const currentPageName = mw.config.get('wgPageName'); | |||
const scriptToImport = pageScripts[currentPageName]; | |||
if (scriptToImport) { | |||
importScript(scriptToImport); | |||
} |
2023年9月27日 (三) 19:24的版本
/* 这里的任何JavaScript将为所有用户在每次页面加载时加载。 */
function addCssFile(cssUrl) {
var link = document.createElement("link");
link.rel = "stylesheet";
link.href = cssUrl;
document.head.appendChild(link);
}
function addJsFile(jsUrl) {
var script = document.createElement("script");
script.src = jsUrl;
document.head.appendChild(script);
}
const pageScripts = {
'首页': 'MediaWiki:Mainpage.js'
};
const currentPageName = mw.config.get('wgPageName');
const scriptToImport = pageScripts[currentPageName];
if (scriptToImport) {
importScript(scriptToImport);
}