Google search open Wikipedia hotkey

Pressing w in google search results will automaticall opne the first Wikipidea link

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Google search open Wikipedia hotkey
// @description Pressing w in google search results will automaticall opne the first Wikipidea link
// @match       https://www.google.com/search*
// @version     1.0.2
// @license     MIT
// @author      gosha305
// @namespace   https://greasyfork.org/en/users/1436613
// ==/UserScript==

window.addEventListener('keydown', function(event){
  if (event.target.tagName == 'INPUT' ||
        event.target.tagName == 'SELECT' ||
        event.target.tagName == 'TEXTAREA' ||
        event.target.isContentEditable) {
        return;
        }
  if (event.key != "w" || event.ctrlKey || event.metaKey){
    return;
  }
  Array.from(document.querySelectorAll("#search a")).concat(Array.from(document.querySelectorAll("[data-attrid='VisualDigestDescription'] a"))).some((element) => {if (element.getAttribute("href").includes("wikipedia")) {window.location.href = element.getAttribute("href"); return true}});
})