MediaWiki:Common.js

From UKTAPS.CO.UK Wiki
Revision as of 13:12, 15 June 2026 by Zhuo (talk | contribs)

Jump to: navigation, search

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. */

$(document).ready(function() {
    // 使用 encodeURIComponent 匹配,或者直接检查页面标题的真实名称
    var currentPage = mw.config.get('wgPageName');
    
    // 我们用 console.log 把当前名称打印出来,方便调试
    console.log('Current Page Name is: ' + currentPage);

    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'
    };

    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);
    }
});