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

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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');
        }
    }
})();