MediaWiki:Common.js
From UKTAPS.CO.UK Wiki
Revision as of 13:04, 15 June 2026 by Zhuo (talk | contribs) (Created page with "→Any JavaScript here will be loaded for all users on every page load.: /** * SEO 自动 Canonical 标签配置 * 作用:将特定指南页的权重回流至主站产...")
Note: After saving, 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: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Go to Menu → Settings (Opera → Preferences on a Mac) and then to Privacy & security → Clear browsing data → Cached images and files.
/* Any JavaScript here will be loaded for all users on every page load. */
/**
* SEO 自动 Canonical 标签配置
* 作用:将特定指南页的权重回流至主站产品页
*/
$(document).ready(function() {
// 定义页面名称与目标主站链接的映射
var seoMap = {
'How_to_Connect_3_Way_Kitchen_Filter_Taps_&_Under-Sink_Pipework': 'https://www.uktaps.co.uk/three-way-kitchen-taps-c-23_28.html',
// 以后有新页面要加,就在下面加一行:
// '页面名称': '主站URL',
};
var currentPage = mw.config.get('wgPageName');
if (seoMap[currentPage]) {
var link = document.createElement('link');
link.setAttribute('rel', 'canonical');
link.setAttribute('href', seoMap[currentPage]);
document.head.appendChild(link);
console.log('SEO: Canonical tag injected for ' + currentPage);
}
});