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.

Od 08.01.2018.. Pogledajte najnovija verzija.

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