Add Site Search Links To Google Search Result

Add a "Site Results" link onto each Google search result entries to search from that site. The link will be added either in the search result entry's popup menu, or after the green URL below the entry's title.

As of 2018-01-08. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Add Site Search Links To Google Search Result
// @namespace    https://greasyfork.org/en/users/85671-jcunews
// @version      1.0.1
// @description  Add a "Site Results" link onto each Google search result entries to search from that site. The link will be added either in the search result entry's popup menu, or after the green URL below the entry's title.
// @author       jcunews
// @include      *://www.google.*/search*
// @include      *://www.google.*.*/search*
// @grant        none
// ==/UserScript==

document.querySelectorAll("#ires .g").forEach(function(entry, menu, point) {
  if (menu = entry.querySelector(".action-menu-item")) {
    if ((/:\/\/webcache/).test(menu.firstElementChild.href)) {
      point = menu.nextElementSibling;
    } else if (menu.firstElementChild.textContent === "Similar") {
      point = menu;
    } else point = null;
    menu = menu.parentNode.insertBefore(menu.cloneNode(true), point).firstElementChild;
  } else if (menu = entry.querySelector(".f")) {
    menu.insertAdjacentHTML("beforeend", ' - <a class="fl"></a>');
    menu = menu.lastElementChild;
  } else return;
  menu.textContent = "Site Results";
  entry = entry.querySelector(".r>a");
  if (entry.pathname === "/url") {
    point = unescape(entry.search.match(/&url=([^&]+)/)[1]).match(/:\/\/([^:/]+)/)[1];
  } else point = entry.hostname;
  menu.href = location.href.replace(/([&?]q=[^&]+)/, "$1+site:" + escape(point));
  menu.onmousedown = null;
});