// ==UserScript==
// @name Gplex - Old Google Frontend
// @namespace http://tampermonkey.net/
// @version 0.7.1
// @description 2011-2019 Google frontend (public beta release)
// @author lightbeam24
// @match *://www.google.com/search*
// @match *://www.google.com/
// @match *://www.google.com/webhp*
// @match *://www.google.com/gplex
// @match *://www.google.com/Gplex
// @exclude *://*/*!!!*
// @exclude *://www.google.com/maps*
// @exclude *://www.google.com/preferences
// @exclude *://www.google.com/advanced
// @exclude *://www.google.com/sorry
// @exclude *://www.google.com/recaptcha
// @exclude *://www.google.com/finance
// @exclude *://www.google.com/imghp
// @exclude *://www.google.com/videohp
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.com
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_deleteValue
// @grant GM_registerMenuCommand
// @license MIT
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js
// @run-at document-body
// @downloadURL none
// ==/UserScript==
function showMenu(){
window.location = "https://www.google.com/gplex";
}
GM_registerMenuCommand("Go to Gplex settings page", showMenu);
(function() {
'use strict';
document.querySelector("html").setAttribute("gplex","loading");
window["trusted_policy"] = window["trustedTypes"] ? (window["trustedTypes"].createPolicy("gplex-policy", {
createHTML: function(a){
return a;
}
})) : {
createHTML: function(a){
return a;
}
};
let styleHTML = `
`;
class SearchResultAPI {
href;
title;
unmoddedTitle;
itemNo;
description;
src;
width;
height;
iframeUrl;
doc;
refdoc;
heading;
medium;
link;
domain;
bigSrc;
list;
thumbnail;
duration;
constructor(item, type) {
if (type == "result") {
this.href = item.href;
this.title = item.title;
this.unmoddedTitle = item.unmoddedTitle;
this.itemNo = item.itemNo;
this.description = item.description;
}
if (type == "video") {
this.href = item.href;
this.title = item.title;
this.unmoddedTitle = item.unmoddedTitle;
this.itemNo = item.itemNo;
this.description = item.description;
this.thumbnail = item.thumbnail;
this.duration = item.duration;
}
if (type == "image") {
this.itemNo = item.itemNo;
this.src = item.src;
this.width = item.width;
this.height = item.height;
this.iframeUrl = item.iframeUrl;
this.refdoc = item.refdocid;
this.doc = item.docid;
this.link = item.link;
this.title = item.title;
this.domain = item.domain;
this.bigSrc = item.bigSrc;
}
if (type == "block") {
this.itemNo = item.itemNo;
if (item.title) {
this.title = item.title;
}
if (item.heading) {
this.heading = item.heading;
}
if (item.medium) {
this.medium = item.medium;
}
if (item.list) {
this.list = item.list;
}
}
}
}
class SearchSidebarAPI {
title;
sub;
img;
desc;
kc1;
kc2;
kc3;
kc4;
kc5;
kc6;
kc7;
kc8;
kc9;
kc10;
kc11;
kc12;
constructor(tit, subtit, img, desc, kc1, kc2, kc3, kc4, kc5, kc6, kc7, kc8, kc9, kc10, kc11, kc12) {
if (tit != null) {
this.title = tit;
this.sub = subtit;
this.img = img;
this.desc = desc;
this.kc1 = kc1;
this.kc2 = kc2;
this.kc3 = kc3;
this.kc4 = kc4;
this.kc5 = kc5;
this.kc6 = kc6;
this.kc7 = kc7;
this.kc8 = kc8;
this.kc9 = kc9;
this.kc10 = kc10;
this.kc11 = kc11;
this.kc12 = kc12;
}
}
}
let UImessages = {
"l2019": "2019",
"l2018": "2017-2018",
"l2016": "2016",
"l2016C": "2016 (Cardified experiment)",
"l2016L": "2016 (Legacy/old browser version)",
"l2015": "2015",
"l2015L": "2014-2015 (Legacy/old browser version)",
"l2014": "2014",
"l2013": "Late 2012-2013",
"l2013L": "2013 (Legacy/old browser version)",
"l2012": "Late 2011-Early 2012",
"notonOn": "On",
"notonOff": "Off (compatible with the Google Images Restored extension)",
"forceLoadMsgOn": "On",
"forceLoadMsgOff": "Off",
"forceLoadMsgFast": "Off (experimental fast mode, not recommended)",
"NEname": "Username",
"NEemail": "Email",
"NEnone": 'None (it will say "account" instead)',
"SDnone": "Never show",
"SDtopbar": "Always show",
"SDtopbarHover": "Show on hover"
};
let linkList = [];
let searchValue;
let searchValueV;
let hasSidebar = false;
let sidebarInfoList = [];
let SB = new SearchSidebarAPI(null);
let loggedIn = "tbd";
let pfp;
let pfp96;
let username;
let email;
let tempSidebarList = [];
let tempUpbarList;
let firstLinkBelongsToBlock = false;
let hasCorrection = false;
let correction;
let insteadLink;
let resultCount;
let url = window.location.href;
let tbs;
let page = 1;
let tempQuery = window.location.href.split("q=");
let location = "all";
let layout = localStorage.getItem("UGF_LAYOUT");
let structuredHP = localStorage.getItem("UGF_STRUCTURED_HOMEPAGE");
let notOnImages = localStorage.getItem("UGF_NOTON_IMAGES");
let forceLoadMsg = localStorage.getItem("UGF_FORCE_LOAD_MSG");
let nameEmail = localStorage.getItem("UGF_NAME_EMAIL");
let settingsDisplay = localStorage.getItem("UGF_SETTINGS_DISPLAY");
let gPlusLink = localStorage.getItem("UGF_PLUS_LINK");
if (url.includes("&tbs=")) {
tbs = window.location.href.split("&tbs=")[1];
if (tbs.includes("&")) {
tbs = tbs.split("&")[0];
}
}
switch (layout) {
case '2010':
document.querySelector("html").setAttribute("layout","2010");
break;
case '2011':
document.querySelector("html").setAttribute("layout","2011");
break;
case '2012':
document.querySelector("html").setAttribute("layout","2012");
document.querySelector("html").setAttribute("legacy-images","");
document.querySelector("html").setAttribute("legacy-gbar","");
document.querySelector("html").setAttribute("legacy-footer","");
break;
case '2013':
document.querySelector("html").setAttribute("layout","2013");
document.querySelector("html").setAttribute("legacy-footer","");
//document.querySelector("html").setAttribute("fake-spa","");
break;
case '2013L':
document.querySelector("html").setAttribute("layout","2013L");
document.querySelector("html").setAttribute("legacy-images","");
document.querySelector("html").setAttribute("legacy-gbar","");
document.querySelector("html").setAttribute("legacy-footer","");
break;
case '2014':
document.querySelector("html").setAttribute("layout","2014");
//document.querySelector("html").setAttribute("fake-spa","");
break;
case '2015':
document.querySelector("html").setAttribute("layout","2015");
//document.querySelector("html").setAttribute("fake-spa","");
break;
case '2015L':
document.querySelector("html").setAttribute("layout","2015L");
document.querySelector("html").setAttribute("legacy-images","");
document.querySelector("html").setAttribute("legacy-gbar","");
document.querySelector("html").setAttribute("legacy-footer","");
break;
case '2016':
document.querySelector("html").setAttribute("layout","2016");
//document.querySelector("html").setAttribute("fake-spa","");
break;
case "2016C":
document.querySelector("html").setAttribute("layout","2016C");
break;
case '2016L':
document.querySelector("html").setAttribute("layout","2016L");
document.querySelector("html").setAttribute("legacy-images","");
document.querySelector("html").setAttribute("legacy-gbar","");
document.querySelector("html").setAttribute("legacy-footer","");
break;
case "2018":
document.querySelector("html").setAttribute("layout","2018");
break;
case "2019":
document.querySelector("html").setAttribute("layout","2019");
break;
default:
document.querySelector("html").setAttribute("layout","2015");
localStorage.setItem("UGF_LAYOUT","2015");
}
if (structuredHP == null) {
localStorage.setItem("UGF_STRUCTURED_HOMEPAGE","false");
structuredHP = "false";
}
if (notOnImages == null) {
localStorage.setItem("UGF_NOTON_IMAGES","false");
notOnImages = "false";
}
if (forceLoadMsg == null) {
localStorage.setItem("UGF_FORCE_LOAD_MSG","true");
forceLoadMsg = "true";
}
if (nameEmail == null) {
localStorage.setItem("UGF_NAME_EMAIL","name");
nameEmail = "name";
}
if (settingsDisplay == null) {
localStorage.setItem("UGF_SETTINGS_DISPLAY","topbar");
settingsDisplay = "topbar";
}
if (gPlusLink == null) {
localStorage.setItem("UGF_PLUS_LINK","https://plus.google.com/");
gPlusLink = "https://plus.google.com/";
}
switch (notOnImages) {
case "false":
break;
case 'true':
document.querySelector("html").setAttribute("noton-images","");
break;
}
switch (nameEmail) {
case "name":
document.querySelector("html").setAttribute("name-email","name");
break;
case 'email':
document.querySelector("html").setAttribute("name-email","email");
break;
}
switch (settingsDisplay) {
case "none":
break;
case "topbar":
document.querySelector("html").setAttribute("settings-display","topbar");
break;
case 'topbar-hover':
document.querySelector("html").setAttribute("settings-display","topbar-hover");
break;
}
document.querySelector("html").setAttribute("location","all");
if (
url.includes("tbm=isch") ||
url.includes("udm=2")
) {
location = "images";
document.querySelector("html").setAttribute("location","images");
}
if (
url.includes("tbm=vid")
) {
location = "videos";
document.querySelector("html").setAttribute("location","videos");
}
if (
url.includes("tbm=bks") ||
url.includes("tbm=shop") ||
url.includes("tbm=nws")
) {
location = "news";
document.querySelector("html").setAttribute("location","news");
document.querySelector("html").setAttribute("disabled","");
}
if (
url.includes("https://www.google.com/gplex") ||
url.includes("https://www.google.com/Gplex")
) {
location = "gplex";
document.querySelector("html").setAttribute("location","gplex");
}
if (structuredHP == "false") {
if (
url.includes("www.google.com/webhp") ||
url == "https://www.google.com/"
) {
location = "home";
document.querySelector("html").setAttribute("location","home");
}
} else {
if (
url.includes("www.google.com/webhp") ||
url.includes("www.google.com/imghp") ||
url.includes("www.google.com/videohp") ||
url == "https://www.google.com/"
) {
location = "structured-home";
document.querySelector("html").setAttribute("location","structured-home");
}
}
if (
url.includes("&start=10")
) {
page = 2;
}
if (
url.includes("&start=20") ||
url.includes("&start=11")
) {
page = 3;
}
if (
url.includes("&start=30") ||
url.includes("&start=21")
) {
page = 4;
}
if (
url.includes("&start=40") ||
url.includes("&start=31")
) {
page = 5;
}
if (
url.includes("&start=50") ||
url.includes("&start=41")
) {
page = 6;
}
if (
url.includes("&start=60") ||
url.includes("&start=51")
) {
page = 7;
}
if (
url.includes("&start=70") ||
url.includes("&start=61")
) {
page = 8;
}
if (
url.includes("&start=80") ||
url.includes("&start=71")
) {
page = 9;
}
if (
url.includes("&start=90") ||
url.includes("&start=81")
) {
page = 10;
}
if (
url.includes("do") &&
url.includes("a") &&
url.includes("barrel") &&
url.includes("roll") &&
url.includes("x") ||
url.includes("%20times")
) {
let times;
if (url.includes("%20times")) {
times = url.split("times")[0];
times = times.split("roll%20")[1];
times = times.split("%20")[0];
} else {
times = url.split("x")[1];
}
if (times.includes("&")) {
times = times.split("&")[0];
}
if (times.includes("#")) {
times = times.split("#")[0];
}
document.querySelector("body").style.animationDuration = "2s";
if (times >= 10) {
document.querySelector("body").style.animationTimingFunction = "linear";
}
if (times >= 50) {
document.querySelector("body").style.animationDuration = "1s";
}
if (times >= 500) {
document.querySelector("body").style.animationDuration = "0.5s";
}
document.querySelector("body").style.animationName = "roll";
document.querySelector("body").style.animationIterationCount = times;
document.querySelector("body").style.animationTimingFunction = "linear";
if (
url.includes("%20reverse") ||
url.includes("%20backwards")
) {
document.querySelector("body").style.animationDirection = "reverse";
}
}
var canGo = false;
function timeout(durationMs) {
return new Promise((resolve, reject) => {
setTimeout(function() {
resolve();
}, durationMs);
});
}
async function waitForElement(elm) {
while (null == document.querySelector(elm)) {
await new Promise(r => requestAnimationFrame(r));
}
await timeout(300).then(function() {
canGo = true;
return document.querySelector(elm);
});
}
async function waitForElement500(elm) {
while (null == document.querySelector(elm)) {
await new Promise(r => requestAnimationFrame(r));
}
await timeout(500).then(function() {
canGo = true;
return document.querySelector(elm);
});
}
async function waitForElement10(elm) {
while (null == document.querySelector(elm)) {
await new Promise(r => requestAnimationFrame(r));
}
await timeout(10).then(function() {
canGo = true;
return document.querySelector(elm);
});
}
async function waitForElement10M(elm, parent) {
while (null == elm) {
await new Promise(r => requestAnimationFrame(r));
}
await timeout(10).then(function() {
canGo = true;
return parent.querySelector(elm);
});
}
async function waitForElement1000M(elm, parent) {
while (null == elm) {
await new Promise(r => requestAnimationFrame(r));
}
await timeout(100).then(function() {
canGo = true;
return parent.querySelector(elm);
});
}
async function waitForElement100(elm) {
while (null == document.querySelector(elm)) {
await new Promise(r => requestAnimationFrame(r));
}
await timeout(10).then(function() {
canGo = true;
return document.querySelector(elm);
});
}
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
let gPlexHTML = `
Custom Image Page
${UImessages.notonOn}
On: Gplex creates it's own image page, which can have some bugs.
Off: Gplex uses the regular Google image page, which has better functionality, but isn't styled according to the layout.
"Force load results" message
${UImessages.forceLoadMsgOn}
On: When Gplex can't find enough results in the page, it will stall for a few seconds in hopes of finding more results, and show a message with an option to force load the results early. Theoretically more reliable on slow connections.
Off: When Gplex would normally show the message, it will instead force load the results automatically.
Display name
${UImessages.NEname}
Some layouts have a display name (older layouts generally speaking). Your email address was originally displayed, but you can choose to display your username instead. This will not affect account menus.
Google+ custom link
Custom link for Google+ buttons, such as the +You on the gbar, or the topbar on certain layouts. Defaults to https://plus.google.com/, which redirects to a notice that Google+ has been discontinued.
`;
let normalHTML = `
`;
let homepageHTML = `
`;
if (
!window.location.href.includes("https://www.google.com/sorry") &&
!window.location.href.includes("https://www.google.com/recaptcha") &&
!window.location.href.includes("imgres") &&
!window.location.href.includes("tbm=nws") &&
!window.location.href.includes("tbm=shop") &&
!window.location.href.includes("tbm=bks")
) {
doSetup(location);
}
if (location == "gplex") {
createCSS();
setTimeout(function() {
createCSS();
}, 100);
setTimeout(function() {
createCSS();
}, 500);
setTimeout(function() {
createCSS();
}, 3000);
setTimeout(function() {
createCSS();
}, 10000);
} else {
createCSS();
}
async function putThroughPaces(item) {
return new Promise((resolve, reject) => {
if (item.tagName == "BLOCK-COMPONENT") {
resolve("block");
}
let i = 0;
// for (i = 0; i < 9; i++) {
if (item.parentNode) {
if (item.parentNode.tagName == "SPAN") {
if (item.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.class = ".MjjYud") {
resolve(item);
} else {
resolve(item);
}
} else {
resolve("Nope");
}
} else {
resolve("Nope");
}
// }
}
)};
let asArray;
let started = false;
let timeoutNumber = 1204;
document.querySelector("html").setAttribute("logged-in","tbd");
function doSetup(location) {
createPageShell(location).then(function(result) {
if (forceLoadMsg == "fast") {
timeoutNumber = 150;
}
if (document.querySelector("body[data-dt='1']")) {
/*alert("Please disable dark theme in Google Search settings to use Gplex.");
window.location = "https://www.google.com/preferences#tabVal=1";*/
}
if (location == "images" && notOnImages == "true") {
parseHTMLNeo(location);
}
else if (location == "images") {
let doInterval1 = setInterval(function() {
let scripts = document.querySelectorAll("script");
console.log(scripts);
scripts.forEach(itemRoot => {
if (itemRoot.innerHTML.includes("AF_initDataCallback({key: 'ds:1',")) {
itemRoot.id = "the-script";
clearInterval(doInterval1);
}
});
}, 10);
}
let doInterval = setInterval(function() {
asArray = document.querySelectorAll("#rso span > a");
if (location != "images") {
if (asArray.length >= 10) {
parseHTMLNeo(location);
clearInterval(doInterval);
}
if (
asArray.length >= 8 &&
url.includes("barrel")
) {
parseHTMLNeo(location);
clearInterval(doInterval);
}
} else if (location == "images") {
if (asArray.length >= 30) {
parseHTMLNeo(location);
clearInterval(doInterval);
}
} else {
clearInterval(doInterval);
}
}, 10);
setTimeout(function() {
if (forceLoadMsg == "true") {
if (
started == false &&
location !== "gplex" &&
location !== "home"
) {
let container = document.querySelector("#ugf-main");
let newElem = document.createElement("div");
newElem.id = "ugf-load-now-container";
newElem.innerHTML = `
Not enough results found. Results will load in a few seconds...
Force-load results now
`;
container.insertBefore(newElem, container.children[0]);
newElem.querySelector("#ugf-load-now").addEventListener("click", function() {
parseHTMLNeo(location);
clearInterval(doInterval);
newElem.remove();
});
}
} else {
clearInterval(doInterval);
if (
started == false &&
location !== "home" &&
location !== "gplex"
) {
parseHTMLNeo(location);
}
}
}, timeoutNumber);
setTimeout(function() {
clearInterval(doInterval);
if (
started == false &&
location !== "home" &&
location !== "gplex"
) {
parseHTMLNeo(location);
}
}, 5000);
});
}
function parseHTMLNeo(location) {
if (started == false) {
started = true;
if (location == "images") {
let newImagesExp = false;
let tempImageList;
if (document.querySelector("body > c-wiz")) {
newImagesExp = true;
tempImageList = document.querySelectorAll("a > div > img");
} else {
tempImageList = document.querySelectorAll("h3 img");
}
let check = 0;
let itemNo = 0;
tempImageList.forEach(itemRoot => {
let alt = itemRoot.getAttribute('alt');
itemRoot.classList.add("ugf-image-parse");
if (alt === null) {
// not there
} else if (alt === '') {
// empty
// check if it is height 12 for favicon later on
} else if (alt === 'Google') {
// google, ignore
} else if (itemRoot.getAttribute("src") == "data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==") {
// pixel, ignore
} else {
let forIframe;
if (newImagesExp) {
if (document.querySelector("#the-script")) {
// setTimeout(function() {
let topdog = itemRoot.parentNode.parentNode.parentNode;
// topdog.querySelector("a").click();
// var imgved = topdog.getAttribute("data-ved");*/
var imgdoc = topdog.getAttribute("data-id");
// search script
var imgfind = document.querySelector("#the-script").innerHTML.split(imgdoc)[1];
//alert(imgfind);
imgfind = imgfind.split('"2008": ')[0];
//console.log(imgfind);
imgfind = imgfind.split('"2003":[null,"')[1];
//alert(imgfind);
imgfind = imgfind.split('"')[0];
console.log(imgfind);
var mera = topdog.querySelector("a:nth-of-type(2)");
var domain;
if (mera.querySelector("div")) {
var link = mera.getAttribute("href");
var title = mera.querySelector("div:nth-child(2)").textContent;
domain = link.split("//")[1];
domain = domain.split("/")[0];
if (domain.includes("www.")) {
domain = domain.split("www.")[1];
}
}
forIframe = "https://www.google.com/imgres?q=" + searchValue + "&docid=" + imgfind + "&tbnid=" + imgdoc;
linkList.push({imageResult: {
itemNo: itemNo,
type: "image",
iframeUrl: forIframe,
width: itemRoot.getAttribute("width"),
height: itemRoot.getAttribute("height"),
refdocid: imgfind,
docid: imgdoc,
link: link,
title: title,
domain: domain,
src: itemRoot.getAttribute("src")
}});
console.log(linkList);
createItem(linkList[itemNo], "imageResult");
itemNo++;
} else {
var elm = "#the-script";
waitForElement10(elm).then(function(elm) {
if (canGo != false) {
// setTimeout(function() {
let topdog = itemRoot.parentNode.parentNode.parentNode;
// topdog.querySelector("a").click();
// var imgved = topdog.getAttribute("data-ved");*/
var imgdoc = topdog.getAttribute("data-id");
// search script
var imgfind = document.querySelector("#the-script").innerHTML.split(imgdoc)[1];
//alert(imgfind);
imgfind = imgfind.split('"2008": ')[0];
//console.log(imgfind);
imgfind = imgfind.split('"2003":[null,"')[1];
//alert(imgfind);
imgfind = imgfind.split('"')[0];
console.log(imgfind);
var mera = topdog.querySelector("a:nth-of-type(2)");
var domain;
if (mera.querySelector("div")) {
var link = mera.getAttribute("href");
var title = mera.querySelector("div:nth-child(2)").textContent;
domain = link.split("//")[1];
domain = domain.split("/")[0];
if (domain.includes("www.")) {
domain = domain.split("www.")[1];
}
}
forIframe = "https://www.google.com/imgres?q=" + searchValue + "&docid=" + imgfind + "&tbnid=" + imgdoc;
linkList.push({imageResult: {
itemNo: itemNo,
type: "image",
iframeUrl: forIframe,
width: itemRoot.getAttribute("width"),
height: itemRoot.getAttribute("height"),
refdocid: imgfind,
docid: imgdoc,
link: link,
title: title,
domain: domain,
src: itemRoot.getAttribute("src")
}});
console.log(linkList);
createItem(linkList[itemNo], "imageResult");
itemNo++;
}
});
}
} else {
var refdoc = itemRoot.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.getAttribute("data-ref-docid");
var imgdoc = itemRoot.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.getAttribute("data-docid");
var mera = itemRoot.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector("div:nth-child(3)");
var domain;
if (mera.querySelector("a")) {
var link = mera.querySelector("a").getAttribute("href");
var title = mera.querySelector("a").textContent;
domain = link.split("//")[1];
domain = domain.split("/")[0];
if (domain.includes("www.")) {
domain = domain.split("www.")[1];
}
} else {
//var elm = document.querySelectorAll(".ugf-image-parse")[itemNo];
var elm = mera.querySelector("a");
waitForElement10M(elm).then(function(elm) {
if (canGo != false) {
var link = mera.querySelector("a").getAttribute("href");
var title = mera.querySelector("a > div:nth-of-type(2)").textContent;
domain = link.split("//")[1];
domain = domain.split("/")[0];
if (domain.includes("www.")) {
domain = domain.split("www.")[1];
}
}
});
}
forIframe = "https://www.google.com/imgres?q=" + searchValue + "&docid=" + refdoc + "&tbnid=" + imgdoc;
linkList.push({imageResult: {
itemNo: itemNo,
type: "image",
iframeUrl: forIframe,
width: itemRoot.getAttribute("width"),
height: itemRoot.getAttribute("height"),
refdocid: refdoc,
docid: imgdoc,
link: link,
title: title,
domain: domain,
src: itemRoot.getAttribute("src")
}});
createItem(linkList[itemNo], "imageResult");
itemNo++;
}
}
check++;
});
// document.querySelector("html").setAttribute("disabled","");
}
else {
let searchValueArray = searchValue.split(" ");
let tempLinkList = document.querySelectorAll("a");
let tempBCList = document.querySelectorAll("block-component");
let check = 0;
let itemNo = 0;
tempLinkList.forEach(itemRoot => {
itemRoot.classList.add("ugf-parse-item"); // [role="heading"].parentNode x4
});
tempBCList.forEach(itemRoot => {
itemRoot.classList.add("ugf-parse-item"); // [role="heading"].parentNode x4
});
tempLinkList = document.querySelectorAll(".ugf-parse-item");
tempLinkList.forEach(itemRoot => {
putThroughPaces(itemRoot).then(function(result) {
if (result == "Nope") {
} else if (result == "block") {
let title;
let heading;
let medium;
let list;
if (itemRoot.querySelector('[role="heading"][aria-level="2"]')) {
title = itemRoot.querySelector('[role="heading"]').innerHTML;
title.style.background = "red";
let nextElem = itemRoot.querySelector('[role="heading"]').parentNode.nextSibling;
nextElem.style.background = "blue";
heading = nextElem.textContent;
} else if (itemRoot.querySelector('[data-attrid="wa:/description"]') == null) {
medium = itemRoot.querySelector('[role="heading"]').innerHTML;
if (itemRoot.querySelector('[role="heading"]').nextSibling) {
list = itemRoot.querySelector('[role="heading"]').nextSibling.innerHTML;
}
}
if (itemRoot.querySelector('[data-attrid="wa:/description"]')) {
medium = itemRoot.querySelector('[data-attrid="wa:/description"]').innerHTML;
}
if (itemRoot.querySelector("a")) {
firstLinkBelongsToBlock = true;
}
if (heading && medium && heading.textContent == medium.textContent) {
//...
heading = title;
title = "";
}
linkList.push({searchInfoBlock: {
itemNo: itemNo,
type: "block",
title: title,
heading: heading,
medium: medium,
list: list
}});
createItem(linkList[itemNo], "searchBlock");
itemNo++;
} else {
let link = result.href;
let title;
let unmoddedTitle;
let description = "";
if (result.querySelector("h3")) {
title = result.querySelector("h3").innerHTML;
unmoddedTitle = result.querySelector("h3").textContent;
searchValueArray.forEach(itemRoot => {
if (
itemRoot == "to" ||
itemRoot == "in" ||
itemRoot == "the" ||
itemRoot == "a" ||
itemRoot == "of" ||
itemRoot == "an" ||
itemRoot == "span" ||
itemRoot == "class" ||
itemRoot == "=" ||
itemRoot == "pan" ||
itemRoot == "sp" ||
itemRoot == "spa" ||
itemRoot == "cl" ||
itemRoot == "cla" ||
itemRoot == "clas" ||
itemRoot == "as" ||
itemRoot == "ass" ||
itemRoot == "lass" ||
itemRoot == "las" ||
itemRoot == "a" ||
itemRoot == "A" ||
itemRoot == "b" ||
itemRoot == "B" ||
itemRoot == "c" ||
itemRoot == "C" ||
itemRoot == "d" ||
itemRoot == "D" ||
itemRoot == "e" ||
itemRoot == "E" ||
itemRoot == "f" ||
itemRoot == "F" ||
itemRoot == "g" ||
itemRoot == "G" ||
itemRoot == "h" ||
itemRoot == "H" ||
itemRoot == "i" ||
itemRoot == "I" ||
itemRoot == "j" ||
itemRoot == "J" ||
itemRoot == "k" ||
itemRoot == "K" ||
itemRoot == "l" ||
itemRoot == "L" ||
itemRoot == "m" ||
itemRoot == "M" ||
itemRoot == "n" ||
itemRoot == "N" ||
itemRoot == "o" ||
itemRoot == "O" ||
itemRoot == "p" ||
itemRoot == "p" ||
itemRoot == "q" ||
itemRoot == "Q" ||
itemRoot == "r" ||
itemRoot == "R" ||
itemRoot == "s" ||
itemRoot == "S" ||
itemRoot == "t" ||
itemRoot == "T" ||
itemRoot == "u" ||
itemRoot == "U" ||
itemRoot == "v" ||
itemRoot == "V" ||
itemRoot == "w" ||
itemRoot == "W" ||
itemRoot == "x" ||
itemRoot == "X" ||
itemRoot == "y" ||
itemRoot == "Y" ||
itemRoot == "z" ||
itemRoot == "Z"
) {
} else {
title = title.replaceAll(itemRoot,"" + itemRoot + "");
let lowerCaseValue = itemRoot.toLowerCase();
title = title.replaceAll(lowerCaseValue,"" + lowerCaseValue + "");
let upperCaseValue = itemRoot.toUpperCase();
title = title.replaceAll(upperCaseValue,"" + upperCaseValue + "");
let normalCaseValue = capitalizeFirstLetter(itemRoot);
title = title.replaceAll(normalCaseValue,"" + normalCaseValue + "");
}
});
}
if (result.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('[data-sncf="1"]')) {
description = result.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('[data-sncf="1"]').innerHTML;
} else if (result.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('[data-sncf="2"]')) {
description = result.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('[data-sncf="2"]').innerHTML;
} else if (result.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('[data-sncf="3"]')) {
description = result.parentNode.parentNode.parentNode.parentNode.parentNode.querySelector('[data-sncf="3"]').innerHTML;
}
let isVideo = false;
if (
result.parentNode.parentNode.parentNode.parentNode.nextSibling &&
result.parentNode.parentNode.parentNode.parentNode.nextSibling.querySelector("img")
) {
isVideo = true;
} else if (
location == "videos" &&
result.parentNode.parentNode.parentNode.parentNode.nextSibling &&
result.parentNode.parentNode.parentNode.parentNode.nextSibling.querySelector("img")
) {
isVideo = true;
}
if (
isVideo == true &&
result.parentNode.parentNode.parentNode.parentNode.nextSibling.querySelector("[role='presentation'] span")
) {
let nextElem = result.parentNode.parentNode.parentNode.parentNode.nextSibling;
let thumbnail = nextElem.querySelector("img").src;
let duration = "361:97";
if (nextElem.querySelector("[role='presentation'] span")) {
duration = nextElem.querySelector("[role='presentation'] span").textContent;
}
if (nextElem.querySelector("a + div > div")) {
description = nextElem.querySelector("a + div > div").innerHTML;
}
linkList.push({videoResult: {
itemNo: itemNo,
type: "video",
href: link,
title: title,
unmoddedTitle: unmoddedTitle,
description: description,
thumbnail: thumbnail,
duration: duration
}});
createItem(linkList[itemNo], "videoResult");
document.querySelector("html").setAttribute("results-arrived","");
itemNo++;
} else if (title != null) {
linkList.push({searchResult: {
itemNo: itemNo,
type: "result",
href: link,
title: title,
unmoddedTitle: unmoddedTitle,
description: description
}});
createItem(linkList[itemNo], "searchResult");
document.querySelector("html").setAttribute("results-arrived","");
itemNo++;
}
}
});
check++;
});
if (
document.querySelector('[role="complementary"]') &&
document.querySelector('body > div > div > div [data-attrid]')
) {
hasSidebar = true;
if (document.querySelector('body > div > div > div > div[data-hveid]:not([role="complementary"]) [data-attrid]')) {
tempUpbarList = document.querySelector('body > div > div > div> div[data-hveid]').querySelectorAll("[data-attrid]");
var elm = "[data-attrid='description']";
waitForElement(elm).then(function(elm) {
if (canGo != false) {
doSidebar(2);
}
});
} else {
doSidebar(1);
}
}
if (document.querySelector("omnient-visibility-control")) {
if (
document.querySelector("omnient-visibility-control location-permission-button") ||
document.querySelector("omnient-visibility-control g-dialog")
) {
} else if (document.querySelector("omnient-visibility-control div") == null) {
if (document.querySelectorAll("omnient-visibility-control a")[1] == null) {
hasCorrection = "type1legacy";
correction = document.querySelector("omnient-visibility-control a").outerHTML;
} else {
hasCorrection = "type2legacy";
correction = document.querySelector("omnient-visibility-control a").outerHTML;
insteadLink = document.querySelectorAll("omnient-visibility-control a")[1].outerHTML;
}
} else {
if (document.querySelector("omnient-visibility-control span span:nth-of-type(3)")) {
hasCorrection = "type2";
insteadLink = document.querySelector("omnient-visibility-control span span:nth-of-type(3)").querySelector("a").getAttribute("href");
} else {
hasCorrection = "type1";
}
correction = document.querySelector("omnient-visibility-control span span:nth-of-type(2)").innerHTML;
}
}
if (document.querySelector('#rso .card-section')) {
let newISHHome = document.querySelector("#ugf-search-results-reserved-fake-iframe");
let toBeMoved = document.querySelector('#rso .card-section');
newISHHome.appendChild(toBeMoved);
document.querySelector("html").setAttribute("has-fake-iframe","");
}
if (
document.querySelector('#rso g-lightbox') &&
document.querySelector('#rso block-component')
) {
let newISHHome = document.querySelector("#ugf-search-results-reserved-fake-iframe");
let toBeMoved = document.querySelector('#rso block-component');
newISHHome.appendChild(toBeMoved);
document.querySelector("html").setAttribute("has-fake-iframe","");
}
if (hasCorrection == "type1") {
createCorrection(correction);
}
if (hasCorrection == "type2") {
createCorrection2(correction);
}
if (hasCorrection == "type1legacy") {
createCorrection1l(correction);
}
if (hasCorrection == "type2legacy") {
createCorrection2l(correction);
}
if (
location == "all" &&
!searchValue.includes(" x ") &&
!searchValue.includes(" X ") &&
searchValue.includes("twitter") ||
searchValue.includes("Twitter") ||
searchValue.includes("TWITTER")
) {
bringForthJustice();
}
if (
searchValue == "Is Mark Zuckerberg a lizard" ||
searchValue == "Is mark zuckerberg a lizard" ||
searchValue == "is mark zuckerberg a lizard" ||
searchValue == "is Mark Zuckerberg a lizard"
) {
createItem("zucc");
document.querySelector("html").setAttribute("lizard","");
}
}
}
}
function doSidebar(mode) {
if (
mode == 2 &&
document.querySelectorAll('[role="complementary"]')[2]
) {
tempSidebarList = document.querySelectorAll('[role="complementary"]')[2].querySelectorAll("[data-attrid]");
} else {
tempSidebarList = document.querySelector('[role="complementary"]').querySelectorAll("[data-attrid]");
}
let sidebarTitle;
let sidebarSubtitle = "";
let sbImg = "";
let sbDesc = "";
let sbKc1 = "";
let sbKc2 = "";
let sbKc3 = "";
let sbKc4 = "";
let sbKc5 = "";
let sbKc6 = "";
let sbKc7 = "";
let sbKc8 = "";
let sbKc9 = "";
let sbKc10 = "";
let sbKc11 = "";
let sbKc12 = "";
tempSidebarList.forEach(itemRoot => {
var itemId = itemRoot.getAttribute("data-attrid");
if (itemId == "title") {
sidebarTitle = itemRoot.innerHTML;
}
if (itemId == "subtitle") {
sidebarSubtitle = itemRoot.innerHTML;
}
if (itemId == "image") {
sbImg = itemRoot.querySelector("img").getAttribute("src");
}
if (
itemId == "description"
) {
sbDesc = itemRoot.innerHTML;
}
/*if (
document.querySelector("[data-attrid='description']")
) {
sbDesc = document.querySelector("[data-attrid='description']").innerHTML;
}*/
if (
!itemId.includes("kc:/ugc:user_reviews") &&
!itemId.includes("kc:/film/film:media_actions_wholepage") &&
!itemId.includes("kc:/ugc:thumbs_up") &&
itemId.includes("kc:/") ||
itemId.includes("ss:/")
) {
if (sbKc1 === "") {
sbKc1 = itemRoot.innerHTML;
} else if (sbKc2 === "") {
sbKc2 = itemRoot.innerHTML;
} else if (sbKc3 === "") {
sbKc3 = itemRoot.innerHTML;
} else if (sbKc4 === "") {
sbKc4 = itemRoot.innerHTML;
} else if (sbKc5 === "") {
sbKc5 = itemRoot.innerHTML;
} else if (sbKc6 === "") {
sbKc6 = itemRoot.innerHTML;
} else if (sbKc7 === "") {
sbKc7 = itemRoot.innerHTML;
} else if (sbKc8 === "") {
sbKc8 = itemRoot.innerHTML;
} else if (sbKc9 === "") {
sbKc9 = itemRoot.innerHTML;
} else if (sbKc10 === "") {
sbKc10 = itemRoot.innerHTML;
} else if (sbKc11 === "") {
sbKc11 = itemRoot.innerHTML;
} else if (sbKc12 === "") {
sbKc12 = itemRoot.innerHTML;
}
}
});
if (mode == 2) {
tempUpbarList.forEach(itemRoot => {
var itemId = itemRoot.getAttribute("data-attrid");
if (itemId == "title") {
sidebarTitle = itemRoot.textContent;
}
if (itemId == "subtitle") {
sidebarSubtitle = itemRoot.textContent;
}
});
}
if (sidebarTitle.includes("See results about")) {
} else {
SB = new SearchSidebarAPI(sidebarTitle, sidebarSubtitle, sbImg, sbDesc, sbKc1, sbKc2, sbKc3, sbKc4, sbKc5, sbKc6, sbKc7, sbKc8, sbKc9, sbKc10, sbKc11, sbKc12);
if (document.querySelector("#ugf-right-inner")) {
createSidebar();
} else {
var elm = "#ugf-right-inner";
waitForElement10(elm).then(function(elm) {
if (canGo != false) {
createSidebar();
}
});
}
}
}
function createCSS() {
if (document.querySelector("#ugf-styles")) {
} else {
let container = document.querySelector("body");
let newElem = document.createElement("div");
newElem.id = "ugf-styles";
newElem.innerHTML = trusted_policy.createHTML(styleHTML);
container.insertBefore(newElem, container.children[0]);
}
}
async function createPageShell(location) {
document.querySelector("html").setAttribute("gplex","");
return new Promise((resolve, reject) => {
let container = document.querySelector("body");
let newElem = document.createElement("div");
newElem.id = "ugf";
if (location == "gplex") {
container = document.querySelector("html");
container.setAttribute("confirmed-sv","");
container.innerHTML = ``;
newElem.innerHTML = trusted_policy.createHTML(gPlexHTML);
} else if (location !== "home") {
newElem.innerHTML = trusted_policy.createHTML(normalHTML);
} else {
newElem.innerHTML = trusted_policy.createHTML(homepageHTML);
}
container.insertBefore(newElem, container.children[0]);
if (location == "home") {
document.querySelector("#ugf-hp-search input").focus();
}
if (location == "gplex") {
document.title = "Gplex Settings";
document.querySelector("#ugf-layout-dd-btn").addEventListener("click",function() {
document.querySelector("html").setAttribute("layout-dd-open","");
document.title = "Gplex Settings";
});
document.querySelector("#ugf-noton-dd-btn").addEventListener("click",function() {
document.querySelector("html").setAttribute("noton-dd-open","");
document.title = "Gplex Settings";
});
document.querySelector("#ugf-forceload-dd-btn").addEventListener("click",function() {
document.querySelector("html").setAttribute("forceload-dd-open","");
document.title = "Gplex Settings";
});
document.querySelector("#ugf-settings-display-dd-btn").addEventListener("click",function() {
document.querySelector("html").setAttribute("settings-display-dd-open","");
document.title = "Gplex Settings";
});
document.querySelector("#ugf-name-email-dd-btn").addEventListener("click",function() {
document.querySelector("html").setAttribute("name-email-dd-open","");
document.title = "Gplex Settings";
});
document.querySelector("#ugf-layout-fence").addEventListener("click",function() {
document.querySelector("html").removeAttribute("layout-dd-open");
});
document.querySelector("#ugf-noton-fence").addEventListener("click",function() {
document.querySelector("html").removeAttribute("noton-dd-open");
});
document.querySelector("#ugf-forceload-fence").addEventListener("click",function() {
document.querySelector("html").removeAttribute("forceload-dd-open");
});
document.querySelector("#ugf-settings-display-fence").addEventListener("click",function() {
document.querySelector("html").removeAttribute("settings-display-dd-open");
});
document.querySelector("#ugf-name-email-fence").addEventListener("click",function() {
document.querySelector("html").removeAttribute("name-email-dd-open");
});
let layoutBtns = document.querySelectorAll("#ugf-option-layout .ugf-dropdown-item");
layoutBtns.forEach(itemRoot => {
itemRoot.addEventListener("click",function() {
let value = itemRoot.getAttribute("value");
document.querySelector("html").setAttribute("layout",value);
localStorage.setItem("UGF_LAYOUT",value);
layout = value;
doGplexDropdowns("layout");
document.querySelector("html").removeAttribute("layout-dd-open");
});
});
let notonBtns = document.querySelectorAll("#ugf-option-noton .ugf-dropdown-item");
notonBtns.forEach(itemRoot => {
itemRoot.addEventListener("click",function() {
let value = itemRoot.getAttribute("value");
localStorage.setItem("UGF_NOTON_IMAGES",value);
notOnImages = value;
doGplexDropdowns("noton");
document.querySelector("html").removeAttribute("noton-dd-open");
});
});
let forceloadBtns = document.querySelectorAll("#ugf-option-forceload .ugf-dropdown-item");
forceloadBtns.forEach(itemRoot => {
itemRoot.addEventListener("click",function() {
let value = itemRoot.getAttribute("value");
localStorage.setItem("UGF_FORCE_LOAD_MSG",value);
forceLoadMsg = value;
doGplexDropdowns("forceload");
document.querySelector("html").removeAttribute("forceload-dd-open");
});
});
let settingsDisplayBtns = document.querySelectorAll("#ugf-option-settings-display .ugf-dropdown-item");
settingsDisplayBtns.forEach(itemRoot => {
itemRoot.addEventListener("click",function() {
let value = itemRoot.getAttribute("value");
localStorage.setItem("UGF_SETTINGS_DISPLAY",value);
settingsDisplay = value;
doGplexDropdowns("settings-display");
document.querySelector("html").removeAttribute("settings-display-dd-open");
});
});
let nameEmailBtns = document.querySelectorAll("#ugf-option-name-email .ugf-dropdown-item");
nameEmailBtns.forEach(itemRoot => {
itemRoot.addEventListener("click",function() {
let value = itemRoot.getAttribute("value");
localStorage.setItem("UGF_NAME_EMAIL",value);
nameEmail = value;
doGplexDropdowns("name-email");
document.querySelector("html").removeAttribute("name-email-dd-open");
});
});
document.querySelector("#ugf-option-plus-link input").addEventListener("keydown", function() {
let key = event.key;
if (key == "Enter") {
var value = document.querySelector("#ugf-option-plus-link input").value;
localStorage.setItem("UGF_PLUS_LINK",value);
gPlusLink = value;
document.querySelector("#ugf-option-plus-link").setAttribute("unsaved","false");
} else {
setTimeout(function() {
var value = document.querySelector("#ugf-option-plus-link input").value;
/*if (
!value.includes("http") ||
!value.includes("://")
) {
//document.querySelector("#ugf-option-plus-link").setAttribute("unsaved","error");
} else*/ if (value == gPlusLink) {
document.querySelector("#ugf-option-plus-link").setAttribute("unsaved","false");
} else {
document.querySelector("#ugf-option-plus-link").setAttribute("unsaved","true");
}
}, 10);
}
});
doGplexDropdowns("all");
}
if (document.querySelector("textarea")) {
searchValue = document.querySelector("textarea").value;
document.querySelector("html").setAttribute("confirmed-sv","");
} else if (document.querySelector("input")) {
searchValue = document.querySelector("input").getAttribute("value");
document.querySelector("html").setAttribute("confirmed-sv","");
/*} else if (location == "images") {
var elm = "input";
waitForElement10(elm).then(function(elm) {
if (canGo != false) {
searchValue = document.querySelector("input").getAttribute("value");
document.querySelector("html").setAttribute("confirmed-sv","");
}
});*/
} else {
var elm = "textarea";
waitForElement10(elm).then(function(elm) {
if (canGo != false) {
searchValue = document.querySelector("textarea").value;
document.querySelector("html").setAttribute("confirmed-sv","");
}
});
}
var elm = "[confirmed-sv]";
waitForElement10(elm).then(function(elm) {
if (canGo != false) {
doSearchValueStuff();
resolve("done");
}
});
if (document.querySelector("#result-stats nobr")) {
resultCount = document.querySelector("#result-stats").innerHTML;
document.querySelector("#ugf-search-results-header span").innerHTML = resultCount;
} else {
var elm = "#result-stats";
waitForElement10(elm).then(function(elm) {
if (canGo != false) {
if (document.querySelector("#result-stats nobr")) {
resultCount = document.querySelector("#result-stats").innerHTML;
document.querySelector("#ugf-search-results-header span").innerHTML = resultCount;
}
}
});
}
});
}
function doGplexDropdowns(setting) {
if (setting == "layout" || setting == "all") {
let layoutBtnSpan = document.querySelector("#ugf-option-layout .ugf-dropdown-button span");
switch (layout) {
case '2010':
layoutBtnSpan.textContent = UImessages.l2012;
break;
case '2011':
layoutBtnSpan.textContent = UImessages.l2012;
break;
case '2012':
layoutBtnSpan.textContent = UImessages.l2012;
break;
case '2013':
layoutBtnSpan.textContent = UImessages.l2013;
break;
case '2013L':
layoutBtnSpan.textContent = UImessages.l2013L;
break;
case '2014':
layoutBtnSpan.textContent = UImessages.l2014;
break;
case '2015':
layoutBtnSpan.textContent = UImessages.l2015;
break;
case '2015L':
layoutBtnSpan.textContent = UImessages.l2015L;
break;
case '2016':
layoutBtnSpan.textContent = UImessages.l2016;
break;
case "2016C":
layoutBtnSpan.textContent = UImessages.l2016C;
break;
case '2016L':
layoutBtnSpan.textContent = UImessages.l2016L;
break;
case "2018":
layoutBtnSpan.textContent = UImessages.l2018;
break;
case "2019":
layoutBtnSpan.textContent = UImessages.l2019;
break;
}
}
if (setting == "noton" || setting == "all") {
let notonBtnSpan = document.querySelector("#ugf-option-noton .ugf-dropdown-button span");
switch (notOnImages) {
case 'false':
notonBtnSpan.textContent = UImessages.notonOn;
break;
case 'true':
notonBtnSpan.textContent = UImessages.notonOff;
break;
}
}
if (setting == "forceload" || setting == "all") {
let forceloadBtnSpan = document.querySelector("#ugf-option-forceload .ugf-dropdown-button span");
switch (forceLoadMsg) {
case 'false':
forceloadBtnSpan.textContent = UImessages.forceLoadMsgOff;
break;
case 'true':
forceloadBtnSpan.textContent = UImessages.forceLoadMsgOn;
break;
case 'fast':
forceloadBtnSpan.textContent = UImessages.forceLoadMsgFast;
break;
}
}
if (setting == "settings-display" || setting == "all") {
let settingsDisplayBtnSpan = document.querySelector("#ugf-option-settings-display .ugf-dropdown-button span");
switch (settingsDisplay) {
case 'topbar':
settingsDisplayBtnSpan.textContent = UImessages.SDtopbar;
break;
case 'topbar-hover':
settingsDisplayBtnSpan.textContent = UImessages.SDtopbarHover;
break;
case 'none':
settingsDisplayBtnSpan.textContent = UImessages.SDnone;
break;
}
}
if (setting == "name-email" || setting == "all") {
let nameEmailBtnSpan = document.querySelector("#ugf-option-name-email .ugf-dropdown-button span");
switch (nameEmail) {
case 'name':
nameEmailBtnSpan.textContent = UImessages.NEname;
break;
case 'email':
nameEmailBtnSpan.textContent = UImessages.NEemail;
break;
case 'none':
nameEmailBtnSpan.textContent = UImessages.NEnone;
break;
}
}
}
function doSearchValueStuff() {
if (
location !== "home" &&
location !== "gplex"
) {
fixSidebar();
}
setLayout();
createTop();
}
function fixSidebar() {
let sidebarTools = document.querySelectorAll(".ugf-sidebar-tool-inner");
sidebarTools.forEach(itemRoot => {
let newHref = itemRoot.getAttribute("href").replaceAll("TEMP_REPLACEME",searchValue);
itemRoot.setAttribute("href",newHref);
});
}
function fixPagination() {
let pages = document.querySelectorAll(".gp-pagination");
let PRcheck = 0;
/*if (loggedIn == true) {
let href = document.querySelector("#gp-pagination-2").getAttribute("href");
document.querySelector("#gp-pagination-2").setAttribute("href",href.replaceAll("&start=10","&start=10"));
href = document.querySelector("#gp-pagination-3").getAttribute("href");
document.querySelector("#gp-pagination-3").setAttribute("href",href.replaceAll("&start=20","&start=110"));
href = document.querySelector("#gp-pagination-4").getAttribute("href");
document.querySelector("#gp-pagination-4").setAttribute("href",href.replaceAll("&start=30","&start=210"));
href = document.querySelector("#gp-pagination-5").getAttribute("href");
document.querySelector("#gp-pagination-5").setAttribute("href",href.replaceAll("&start=40","&start=310"));
href = document.querySelector("#gp-pagination-6").getAttribute("href");
document.querySelector("#gp-pagination-6").setAttribute("href",href.replaceAll("&start=50","&start=410"));
href = document.querySelector("#gp-pagination-7").getAttribute("href");
document.querySelector("#gp-pagination-7").setAttribute("href",href.replaceAll("&start=60","&start=510"));
href = document.querySelector("#gp-pagination-8").getAttribute("href");
document.querySelector("#gp-pagination-8").setAttribute("href",href.replaceAll("&start=70","&start=610"));
href = document.querySelector("#gp-pagination-9").getAttribute("href");
document.querySelector("#gp-pagination-9").setAttribute("href",href.replaceAll("&start=80","&start=710"));
href = document.querySelector("#gp-pagination-10").getAttribute("href");
document.querySelector("#gp-pagination-10").setAttribute("href",href.replaceAll("&start=90","&start=810"));
}*/
pages.forEach(itemRoot => {
let newHref;
if (location == "images") {
newHref = itemRoot.getAttribute("href").replaceAll("TEMP_REPLACEME",searchValue + "&udm=2");
} else if (location == "videos") {
newHref = itemRoot.getAttribute("href").replaceAll("TEMP_REPLACEME",searchValue + "&tbm=vid");
} else {
newHref = itemRoot.getAttribute("href").replaceAll("TEMP_REPLACEME",searchValue);
}
itemRoot.setAttribute("href",newHref);
PRcheck++;
});
let newPrevHref;
let newNextHref;
let prevNumb = page - 2;
let currNumb = page - 1;
document.querySelectorAll("#gp-page-numbers .gp-pagination")[currNumb].classList.add("active");
if (document.querySelectorAll("#gp-page-numbers .gp-pagination")[prevNumb]) {
newPrevHref = document.querySelectorAll("#gp-page-numbers .gp-pagination")[prevNumb].getAttribute("href");
}
if (document.querySelectorAll("#gp-page-numbers .gp-pagination")[page]) {
newNextHref = document.querySelectorAll("#gp-page-numbers .gp-pagination")[page].getAttribute("href");
}
document.querySelector("#gp-pagination-prev").setAttribute("href",newPrevHref);
document.querySelector("#gp-pagination-next").setAttribute("href",newNextHref);
if (page != 1) {
document.querySelector("#gp-pagination-prev").classList.add("has-prev");
}
}
function setLayout() {
if (
//searchValue.includes("so retro") ||
searchValue.includes("SO RETRO") //||
/*searchValue.includes("RETROO") ||
searchValue.includes("retroo") ||
searchValue.includes("RETROING") ||
searchValue.includes("retroing") ||
searchValue.includes("RETROIFY") ||
searchValue.includes("retroify")*/
) {
document.querySelector("html").setAttribute("layout","retro");
}
if (
searchValue == "Google in 2019" ||
searchValue == "google in 2019"
) {
document.querySelector("html").setAttribute("layout","2019");
localStorage.setItem("UGF_LAYOUT","2019");
setTimeout(function() {
checkProperty("legacy-gbar",false);
checkProperty("legacy-footer",false);
}, 1000);
}
if (
searchValue == "Google in 2017" ||
searchValue == "google in 2017" ||
searchValue == "Google in 2018" ||
searchValue == "google in 2018"
) {
document.querySelector("html").setAttribute("layout","2018");
localStorage.setItem("UGF_LAYOUT","2018");
setTimeout(function() {
checkProperty("legacy-gbar",false);
checkProperty("legacy-footer",false);
}, 1000);
}
if (
searchValue == "Google in 2016" ||
searchValue == "google in 2016"
) {
document.querySelector("html").setAttribute("layout","2016");
localStorage.setItem("UGF_LAYOUT","2016");
setTimeout(function() {
checkProperty("legacy-gbar",false);
checkProperty("legacy-footer",false);
}, 1000);
//document.querySelector("html").setAttribute("fake-spa","");
}
if (
searchValue == "Google in 2016C" ||
searchValue == "google in 2016C"
) {
document.querySelector("html").setAttribute("layout","2016C");
localStorage.setItem("UGF_LAYOUT","2016C");
setTimeout(function() {
checkProperty("legacy-gbar",false);
checkProperty("legacy-footer",false);
}, 1000);
}
if (
searchValue == "Google in 2016L" ||
searchValue == "google in 2016L"
) {
document.querySelector("html").setAttribute("layout","2016L");
localStorage.setItem("UGF_LAYOUT","2016L");
setTimeout(function() {
checkProperty("legacy-gbar",true);
checkProperty("legacy-footer",true);
}, 1000);
}
if (
searchValue == "Google in 2015" ||
searchValue == "google in 2015"
) {
document.querySelector("html").setAttribute("layout","2015");
localStorage.setItem("UGF_LAYOUT","2015");
setTimeout(function() {
checkProperty("legacy-gbar",false);
checkProperty("legacy-footer",false);
}, 1000);
//document.querySelector("html").setAttribute("fake-spa","");
}
if (
searchValue == "Google in 2015L" ||
searchValue == "google in 2015L"
) {
document.querySelector("html").setAttribute("layout","2015L");
localStorage.setItem("UGF_LAYOUT","2015L");
setTimeout(function() {
checkProperty("legacy-gbar",true);
checkProperty("legacy-footer",true);
}, 1000);
}
if (
searchValue == "Google in 2014" ||
searchValue == "google in 2014"
) {
document.querySelector("html").setAttribute("layout","2014");
localStorage.setItem("UGF_LAYOUT","2014");
setTimeout(function() {
checkProperty("legacy-gbar",false);
checkProperty("legacy-footer",false);
}, 1000);
//document.querySelector("html").setAttribute("fake-spa","");
}
if (
searchValue == "Google in 2013" ||
searchValue == "google in 2013"
) {
document.querySelector("html").setAttribute("layout","2013");
localStorage.setItem("UGF_LAYOUT","2013");
// timeouts are bad. fix this later.
setTimeout(function() {
checkProperty("legacy-gbar",false);
checkProperty("legacy-footer",true);
}, 1000);
//document.querySelector("html").setAttribute("fake-spa","");
}
if (
searchValue == "Google in 2013L" ||
searchValue == "google in 2013L"
) {
document.querySelector("html").setAttribute("layout","2013L");
localStorage.setItem("UGF_LAYOUT","2013L");
setTimeout(function() {
checkProperty("legacy-gbar",true);
checkProperty("legacy-footer",true);
}, 1000);
}
if (
searchValue == "Google in 2011" ||
searchValue == "google in 2011" ||
searchValue == "Google in 2012" ||
searchValue == "google in 2012"
) {
document.querySelector("html").setAttribute("layout","2012");
localStorage.setItem("UGF_LAYOUT","2012");
setTimeout(function() {
checkProperty("legacy-gbar",true);
checkProperty("legacy-footer",true);
}, 1000);
}
/*if (
searchValue == "Google in 2011" ||
searchValue == "google in 2011"
) {
document.querySelector("html").setAttribute("layout","2011");
localStorage.setItem("UGF_LAYOUT","2011");
}
if (
searchValue == "Google in 2010" ||
searchValue == "google in 2010"
) {
document.querySelector("html").setAttribute("layout","2010");
localStorage.setItem("UGF_LAYOUT","2010");
}*/
}
function checkProperty(property, shouldHave) {
if (document.querySelector("[" + property + "]")) {
if (shouldHave == false) {
document.querySelector("html").removeAttribute(property);
}
} else if (shouldHave == true) {
document.querySelector("html").setAttribute(property,"");
}
}
function bringForthJustice() {
let xValue = searchValue.replaceAll("twitter","x");
let safeXValue = searchValue.replaceAll("twitter","x");
xValue = xValue.replaceAll("Twitter","X");
safeXValue = safeXValue.replaceAll("Twitter","X");
xValue = xValue.replaceAll("TWITTER","𝕏");
safeXValue = safeXValue.replaceAll("TWITTER","𝕏");
let container = document.querySelector("#ugf-search-results-reserved-top");
let newElem = document.createElement("div");
newElem.classList.add("ugf-correction");
newElem.classList.add("ugf-easter-egg");
newElem.innerHTML = `
`;
container.insertBefore(newElem, container.children[0]);
}
function createCorrection(value) {
let container = document.querySelector("#ugf-search-results-reserved-top");
let newElem = document.createElement("div");
newElem.classList.add("ugf-correction");
newElem.innerHTML = `
${value}
`;
container.insertBefore(newElem, container.children[0]);
}
function createCorrection1l(value) {
let container = document.querySelector("#ugf-search-results-reserved-top");
let newElem = document.createElement("div");
newElem.classList.add("ugf-correction");
newElem.innerHTML = `
Did you mean:
${value}
`;
container.insertBefore(newElem, container.children[0]);
}
function createCorrection2(value) {
let container = document.querySelector("#ugf-search-results-reserved-top");
let newElem = document.createElement("div");
newElem.classList.add("ugf-correction-blue");
newElem.innerHTML = `
${value}
`;
container.insertBefore(newElem, container.children[0]);
}
function createCorrection2l(value) {
let container = document.querySelector("#ugf-search-results-reserved-top");
let newElem = document.createElement("div");
newElem.classList.add("ugf-correction-blue");
newElem.innerHTML = `
Showing results for
${value}
Search instead for
"${insteadLink}"
`;
container.insertBefore(newElem, container.children[0]);
}
function createSidebar() {
let container = document.querySelector("#ugf-right-inner");
let newElem = document.createElement("div");
newElem.id = "ugf-side-info-container";
newElem.innerHTML = `
${SB.desc}
${SB.kc1}
${SB.kc2}
${SB.kc3}
${SB.kc4}
${SB.kc5}
${SB.kc6}
${SB.kc7}
${SB.kc8}
${SB.kc9}
${SB.kc10}
${SB.kc11}
${SB.kc12}
`;
container.insertBefore(newElem, container.children[0]);
}
let searchPredictsAPI = [];
function fetchPredicts(value) {
fetch("https://www.google.com/complete/search?q=" + value + "&cp=" + value + "&client=gws-wiz&xssi=t&gs_pcrt=undefined&hl=en-CA&authuser=0&dpr=1", {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"connection": "keep-alive",
"host": "www.google.com",
"referrer": "https://www.google.com/",
"referrerPolicy": "strict-origin-when-cross-origin",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"method": "GET"
}).then(response => response.text()).then(data => {
var cutString1 = data.split(")]}'");
var used = cutString1[1];
data = JSON.parse(used);
var list = data[0];
parsePredicts(list);
});
}
function parsePredicts(list) {
//API
searchPredictsAPI = [];
let itemNo = 0;
list.forEach(itemRoot => {
let text = itemRoot[0];
searchPredictsAPI.push({searchPrediction: {
content: text,
itemNo: itemNo
}});
itemNo++;
});
createPredicts(searchPredictsAPI);
}
function createPredicts(SPAPI) {
if (document.querySelector("#ugf-search-predictions")) {
document.querySelector("#ugf-search-predictions").remove();
}
let container = document.querySelector("#ugf-search-predictions-container");
let newElem = document.createElement("div");
newElem.id = "ugf-search-predictions";
newElem.innerHTML = `
`;
container.insertBefore(newElem, container.children[0]);
document.querySelector("#ugf-search-predictions-fence").addEventListener("click", function() {
document.querySelector("html").removeAttribute("search-focus");
});
SPAPI.forEach(itemRoot => {
createPrediction(itemRoot.searchPrediction);
});
}
function createPrediction(item) {
let container = document.querySelector("#ugf-search-predictions-inner");
let newElem = document.createElement("a");
newElem.classList.add("ugf-search-prediction");
newElem.innerHTML = `
`;
container.insertBefore(newElem, container.children[item.itemNo]);
let a = newElem.textContent;
a = a.trim();
if (location == "images") {
newElem.setAttribute("href","https://www.google.com/search?q=" + a + "&udm=2");
} else {
newElem.setAttribute("href","https://www.google.com/search?q=" + a);
}
/*newElem.addEventListener("click", function() {
var value = newElem.textContent;
if (location == "images") {
window.location = "https://www.google.com/search?q=" + value + "&udm=2";
} else {
window.location = "https://www.google.com/search?q=" + value;
}
});*/
}
function doImageViewer(item) {
document.querySelector("#ugf-image-viewer").innerHTML = ``;
let container = document.querySelector("#ugf-image-viewer");
let newElem = document.createElement("div");
newElem.id = "ugf-image-viewer-inner";
newElem.innerHTML = `
`;
container.insertBefore(newElem, container.children[0]);
}
function createTop() {
let navbarText = "Search";
if (location == "gplex") {
navbarText = "Gplex Settings";
}
let container = document.querySelector("#ugf-top-container");
let newElem = document.createElement("div");
newElem.id = "ugf-top-container-inner";
newElem.innerHTML = `
`;
container.insertBefore(newElem, container.children[0]);
document.querySelector("#gp-gbar-more").addEventListener("click", function() {
document.querySelector("html").setAttribute("gbar-dd-open","");
});
document.querySelector("#gp-gbar-dd-fence").addEventListener("click", function() {
document.querySelector("html").removeAttribute("gbar-dd-open");
});
if (location == "home") {
document.querySelector("#ugf-top #ugf-search").remove();
document.querySelector("#ugf-search-btn-2").addEventListener("click", function() {
document.querySelector("#ugf-search-btn").click();
});
document.querySelector("#ugf-lucky-btn").addEventListener("click", function() {
var value = document.querySelector("#ugf-search-value").value;
value = value.replaceAll("(","%28");
value = value.replaceAll(")","%29");
value = value.replaceAll("+","%2B");
value = value.replaceAll("-","%2D");
value = value.replaceAll("/","%2F");
window.location = "https://www.google.com/search?q=" + value + "&btnI=I%27m+Feeling+Lucky&iflsig=ANes7DEAAAAAZhR3OR8bkupN1D63NUfgJj5erQigfDUN";
});
}
var elm = "[href^='https://accounts.google.com/S']";
waitForElement10(elm).then(function(elm) {
if (canGo != false) {
if (document.querySelector("[href^='https://accounts.google.com/ServiceLogin']")) {
loggedIn = false;
document.querySelector("html").setAttribute("logged-in","false");
}
if (document.querySelector("[href^='https://accounts.google.com/SignOutOptions']")) {
loggedIn = true;
document.querySelector("html").setAttribute("logged-in","true");
pfp = document.querySelector("[href^='https://accounts.google.com/SignOutOptions'] img").getAttribute("src");
pfp96 = pfp.replace("s32","s96");
let cutIt = document.querySelector("[href^='https://accounts.google.com/SignOutOptions']").getAttribute("aria-label").split(": ");
cutIt = cutIt[1];
cutIt = cutIt.split(" \n");
username = cutIt[0];
let firstName = username.split(" ")[0];
email = cutIt[1];
email = email.split("(");
email = email[1];
email = email.split(")");
email = email[0];
document.querySelector("#gp-gbar-account span").textContent = firstName;
document.querySelector("#gp-gbar-email span").textContent = email;
document.querySelector("#ugf-account-username span").textContent = username;
document.querySelector("#ugf-account-email span").textContent = email;
document.querySelector("#ugf-username-button span").textContent = "+" + firstName;
document.querySelector("#ugf-email-button span").textContent = email;
document.querySelector("#ugf-account-button img").src = pfp;
document.querySelector("#ugf-account-pfp img").src = pfp96;
document.querySelector("#ugf-account-normal-pfp img").src = pfp96;
document.querySelector("#gp-gbar-plusyou span").textContent = "+" + firstName;
}
fixPagination();
}
});
if (location == "images") {
document.querySelector("#ugf-all-tab").classList.remove("active");
document.querySelector("#ugf-images-tab").classList.add("active");
document.querySelector("#ugf-page-multistate").setAttribute("state","images");
document.querySelector("#ugf-all-item").classList.remove("active");
document.querySelector("#ugf-images-item").classList.add("active");
document.querySelector("#gp-gbar-search").classList.remove("active");
document.querySelector("#gp-gbar-images").classList.add("active");
}
if (location == "videos") {
document.querySelector("#ugf-all-tab").classList.remove("active");
document.querySelector("#ugf-videos-tab").classList.add("active");
document.querySelector("#ugf-all-item").classList.remove("active");
document.querySelector("#ugf-videos-item").classList.add("active");
}
if (
location !== "home" &&
location !== "gplex"
) {
switch (tbs) {
case 'qdr:h':
document.querySelector("#ugf-hour-tool").classList.add("active");
document.querySelector("#ugf-all-results-tool").classList.add("active");
break;
case 'qdr:d':
document.querySelector("#ugf-day-tool").classList.add("active");
document.querySelector("#ugf-all-results-tool").classList.add("active");
break;
case 'qdr:w':
document.querySelector("#ugf-week-tool").classList.add("active");
document.querySelector("#ugf-all-results-tool").classList.add("active");
break;
case 'qdr:m':
document.querySelector("#ugf-month-tool").classList.add("active");
document.querySelector("#ugf-all-results-tool").classList.add("active");
break;
case 'qdr:y':
document.querySelector("#ugf-year-tool").classList.add("active");
document.querySelector("#ugf-all-results-tool").classList.add("active");
break;
case 'li:1':
document.querySelector("#ugf-any-time-tool").classList.add("active");
document.querySelector("#ugf-verbatim-tool").classList.add("active");
break;
default:
document.querySelector("#ugf-any-time-tool").classList.add("active");
document.querySelector("#ugf-all-results-tool").classList.add("active");
}
document.querySelector("#ugf-search-value").value = searchValue;
document.querySelector("#ugf-all-tab").href = "https://www.google.com/search?q=" + searchValue;
document.querySelector("#ugf-images-tab").href = "https://www.google.com/search?q=" + searchValue + "&udm=2";
document.querySelector("#ugf-videos-tab").href = "https://www.google.com/search?q=" + searchValue + "&tbm=vid";
document.querySelector("#ugf-news-tab").href = "https://www.google.com/search?q=" + searchValue + "&tbm=nws";
document.querySelector("#ugf-maps-tab").href = "https://maps.google.com/maps?q=" + searchValue;
document.querySelector("#ugf-all-item").href = "https://www.google.com/search?q=" + searchValue;
document.querySelector("#ugf-images-item").href = "https://www.google.com/search?q=" + searchValue + "&udm=2";
document.querySelector("#ugf-videos-item").href = "https://www.google.com/search?q=" + searchValue + "&tbm=vid";
document.querySelector("#ugf-news-item").href = "https://www.google.com/search?q=" + searchValue + "&tbm=nws";
document.querySelector("#ugf-maps-item").href = "https://maps.google.com/maps?q=" + searchValue;
linkList.forEach(itemRoot => {
if (itemRoot.searchResult) {
createItem(itemRoot, "searchResult");
}
if (itemRoot.videoResult) {
createItem(itemRoot, "videoResult");
}
if (itemRoot.imageResult) {
createItem(itemRoot, "imageResult");
}
if (itemRoot.searchInfoBlock) {
createItem(itemRoot, "searchBlock");
}
});
}
document.querySelector("#waffle").addEventListener("click", function() {
document.querySelector("html").setAttribute("apps-dd-open","");
});
document.querySelector("#ugf-account-button").addEventListener("click", function() {
document.querySelector("html").setAttribute("account-dd-open","");
});
document.querySelector("#ugf-fake-notifs-button").addEventListener("click", function() {
document.querySelector("html").setAttribute("notifs-dd-open","");
document.querySelector("html").setAttribute("gplus-notif-status","none");
setTimeout(function() {
document.querySelector("#ugf-mr-jingles img").setAttribute("src","https://ssl.gstatic.com/s2/oz/images/notifications/jingles_gif_2x_f3cc6d214824b9711a0e8c1a75d285ff.gif");
}, 250);
});
/*document.querySelector("#ugf-mr-jingles").addEventListener("click", function() {
document.querySelector("#ugf-mr-jingles img").setAttribute("src","https://ssl.gstatic.com/s2/oz/images/notifications/jingles_gif_2x_f3cc6d214824b9711a0e8c1a75d285ff.gif");
});*/
document.querySelector("#ugf-notifs-dd-prev").addEventListener("click", function() {
document.querySelector("html").setAttribute("gplus-notif-status","loading");
setTimeout(function() {
document.querySelector("html").setAttribute("gplus-notif-status","failed");
}, 1000);
});
document.querySelector("#beyond-the-fence").addEventListener("click", function() {
document.querySelector("html").removeAttribute("apps-dd-open");
});
document.querySelector("#beyond-the-fence-2").addEventListener("click", function() {
document.querySelector("html").removeAttribute("account-dd-open");
});
document.querySelector("#beyond-the-fence-3").addEventListener("click", function() {
document.querySelector("html").removeAttribute("notifs-dd-open");
document.querySelector("html").setAttribute("gplus-notif-status","none");
});
document.querySelector("#ugf-search-value").addEventListener("focus", function() {
document.querySelector("html").setAttribute("search-focus","hard");
});
document.querySelector("#ugf-search-value").addEventListener("blur", function() {
document.querySelector("html").setAttribute("search-focus","soft");
document.querySelector("html").setAttribute("hide-results","false");
});
document.querySelector("#ugf-search-btn").addEventListener("click", function() {
var value = document.querySelector("#ugf-search-value").value;
value = value.replaceAll("(","%28");
value = value.replaceAll(")","%29");
value = value.replaceAll("+","%2B");
value = value.replaceAll("-","%2D");
value = value.replaceAll("/","%2F");
if (value == "StructuredHomepageOn") {
localStorage.setItem("UGF_STRUCTURED_HOMEPAGE","true");
window.location.replace("https://www.google.com/");
} else if (value == "StructuredHomepageOff") {
localStorage.setItem("UGF_STRUCTURED_HOMEPAGE","false");
window.location.replace("https://www.google.com/");
}
if (value == "CustomImagePageOn") {
localStorage.setItem("UGF_NOTON_IMAGES","false");
alert("Command accepted");
window.location.replace("https://www.google.com/");
} else if (value == "CustomImagePageOff") {
localStorage.setItem("UGF_NOTON_IMAGES","true");
alert("Command accepted");
window.location.replace("https://www.google.com/");
}
else {
window.location = "https://www.google.com/search?q=" + value;
if (location == "images") {
window.location = "https://www.google.com/search?q=" + value + "&udm=2";
} else if (location == "videos") {
window.location = "https://www.google.com/search?q=" + value + "&tbm=vid";
} else if (location == "news") {
window.location = "https://www.google.com/search?q=" + value + "&tbm=nws";
} else if (location == "maps") {
window.location = "https://maps.google.com/maps?q=" + value;
} else {
window.location = "https://www.google.com/search?q=" + value;
}
}
});
document.querySelector("#ugf-search-value").addEventListener("keydown", function() {
document.querySelector("html").setAttribute("hide-results","true");
let key = event.key;
if (key == "Enter") {
var value = document.querySelector("#ugf-search-value").value;
value = value.replaceAll("(","%28");
value = value.replaceAll(")","%29");
value = value.replaceAll("+","%2B");
value = value.replaceAll("-","%2D");
value = value.replaceAll("/","%2F");
if (value == "StructuredHomepageOn") {
localStorage.setItem("UGF_STRUCTURED_HOMEPAGE","true");
window.location.replace("https://www.google.com/");
} else if (value == "StructuredHomepageOff") {
localStorage.setItem("UGF_STRUCTURED_HOMEPAGE","false");
window.location.replace("https://www.google.com/");
}
if (value == "CustomImagePageOn") {
localStorage.setItem("UGF_NOTON_IMAGES","false");
alert("Command accepted");
window.location.replace("https://www.google.com/");
} else if (value == "CustomImagePageOff") {
localStorage.setItem("UGF_NOTON_IMAGES","true");
alert("Command accepted");
window.location.replace("https://www.google.com/");
}
else {
window.location = "https://www.google.com/search?q=" + value;
if (location == "images") {
window.location = "https://www.google.com/search?q=" + value + "&udm=2";
} else if (location == "videos") {
window.location = "https://www.google.com/search?q=" + value + "&tbm=vid";
} else if (location == "news") {
window.location = "https://www.google.com/search?q=" + value + "&tbm=nws";
} else if (location == "maps") {
window.location = "https://maps.google.com/maps?q=" + value;
} else {
window.location = "https://www.google.com/search?q=" + value;
}
}
} else {
setTimeout(function() { // delay so it gets updated value
var value = document.querySelector("#ugf-search-value").value;
fetchPredicts(value);
}, 50);
}
});
}
function createItem(itemGet, itemType) {
let item;
let type;
let SRA;
if (itemGet == "zucc") {
type = "block";
}
if (itemType == "searchResult") {
item = itemGet.searchResult;
type = item.type;
SRA = new SearchResultAPI(item, type);
}
if (itemType == "videoResult") {
item = itemGet.videoResult;
type = item.type;
SRA = new SearchResultAPI(item, type);
}
if (itemType == "imageResult") {
item = itemGet.imageResult;
type = item.type;
SRA = new SearchResultAPI(item, type);
}
if (itemType == "searchBlock") {
item = itemGet.searchInfoBlock;
type = item.type;
SRA = new SearchResultAPI(item, type);
}
if (type == "result") {
let container = document.querySelector("#ugf-search-results-container");
let newElem = document.createElement("div");
newElem.classList.add("ugf-search-result");
newElem.innerHTML = `
`;
container.insertBefore(newElem, container.children[SRA.itemNo]);
}
if (type == "video") {
let container = document.querySelector("#ugf-search-results-container");
let newElem = document.createElement("div");
newElem.classList.add("ugf-search-result");
newElem.classList.add("ugf-video-result");
newElem.setAttribute("thumb-url",SRA.thumbnail);
newElem.innerHTML = `
`;
container.insertBefore(newElem, container.children[SRA.itemNo]);
}
if (type == "image") {
let container = document.querySelector("#ugf-image-results-container");
let newElem = document.createElement("div");
newElem.classList.add("ugf-image-result");
newElem.setAttribute("iframe-url",SRA.iframeUrl);
newElem.setAttribute("href",SRA.iframeUrl);
newElem.innerHTML = `
${SRA.width}
x
${SRA.height}
${SRA.domain}
${SRA.title}
${SRA.width}
x
${SRA.height}
`;
container.insertBefore(newElem, container.children[SRA.itemNo]);
newElem.addEventListener("click", function() {
var iurl = newElem.getAttribute('iframe-url');
document.querySelector("#ugf-image-iframe iframe").setAttribute("src",iurl);
//doImageViewer(newElem);
});
if (newElem.querySelector("img").getAttribute("src") == "null") {
newElem.remove();
}
}
if (type == "block") {
let container = document.querySelector("#ugf-search-results-reserved-top");
let newElem = document.createElement("div");
newElem.classList.add("ugf-instant-answer");
let blockTitle;
let blockHeading;
let blockMedium;
let blockList;
if (itemGet == "zucc") {
newElem.classList.add("ugf-easter-egg");
blockTitle = "";
blockHeading = "Yes";
blockMedium = "";
blockList = "";
} else {
blockTitle = SRA.title;
blockHeading = SRA.heading;
blockMedium = SRA.medium;
blockList = SRA.list;
}
newElem.innerHTML = `
${blockTitle}
${blockHeading}
${blockMedium}
${blockList}
`;
container.insertBefore(newElem, container.children[0]);
if (blockTitle == null) {
newElem.querySelector(".ugf-instant-answer-supertext").remove();
}
if (blockHeading == null) {
newElem.querySelector(".ugf-instant-answer-heading").remove();
}
if (blockMedium == null) {
newElem.querySelector(".ugf-instant-answer-medium").remove();
}
if (blockList == null) {
newElem.querySelector(".ugf-instant-answer-list").remove();
}
if (firstLinkBelongsToBlock == true) {
var elm = ".ugf-search-result";
waitForElement10(elm).then(function(elm) {
if (canGo != false) {
newElem.appendChild(document.querySelector(".ugf-search-result"));
}
});
}
}
}
})();