修正Google搜尋中的維基百科為桌面版網頁

修正Google搜尋中的維基百科為桌面版網頁。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         修正Google搜尋中的維基百科為桌面版網頁
// @name:en      Changed Wikipedia to desktop webpage in Google search results
// @namespace    http://tampermonkey.net/
// @version      1.1
// @description  修正Google搜尋中的維基百科為桌面版網頁。
// @description:en  Changed Wikipedia to desktop webpage in Google search results.
// @author       vincent8914
// @match        https://www.google.com/search*
// @match        https://www.google.com.tw/search*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    const regexp = /m.wikipedia.org/g;
    var searchResults = document.querySelectorAll('.yuRUbf');
    for(let i = 0; i < searchResults.length; i++){
        if(regexp.test(searchResults[i].innerHTML)){
            searchResults[i].innerHTML = searchResults[i].innerHTML.replace(regexp, 'wikipedia.org');
        }
    }
})();