Greasy Fork is available in English.

Google Search Extra Buttons (Position Slightly Right)

Add buttons (past 1/2/3 days, weeks, PDF search etc.) for Google search page

このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください。
  1. // ==UserScript==
  2. // @name Google Search Extra Buttons (Position Slightly Right)
  3. // @description Add buttons (past 1/2/3 days, weeks, PDF search etc.) for Google search page
  4. // @version 45.2023.10.08
  5. // @namespace spmbt.github.com
  6. // @include http://www.google.*/search*
  7. // @include https://www.google.*/search*
  8. // @include https://www.google.*/*
  9. // @include https://encrypted.google.*/search*
  10. // @include https://encrypted.google.*/*
  11. // @include https://spmbt.github.io/googleSearchExtraButtons/saveYourLocalStorage.html
  12. // @include https://www.gstatic.com/sites/p/b9356d/system/services/test.html
  13. // @include https://www.gstatic.com/index.html
  14. // @license MIT
  15. // ==/UserScript==
  16. // 🕮 <lunde> ef3c5f9a-82e1-4b71-9a8d-7c902e27927b.md
  17. const BASE_POSITION = -127; // Starting position of buttons used in csLeft function
  18. const BUTTON_SPACING = 37; // Spacing between each button
  19. const RIGHT_OFFSET = 180; // Offset from the right
  20.  
  21. var xLocStI = 0,
  22. xLocSto = [
  23. {
  24. origin: "https://spmbt.github.io",
  25. restHref: "/googleSearchExtraButtons/saveYourLocalStorage.html",
  26. },
  27. {
  28. origin: "https://www.gstatic.com",
  29. restHref: "/sites/p/b9356d/system/services/test.html",
  30. "//": "blank page",
  31. },
  32. {
  33. origin: "https://www.gstatic.com",
  34. restHref: "/index.html",
  35. "//": "404 page",
  36. },
  37. ];
  38. // For use own eXternal LocalStorage add to array your origin+restHref of site with https protocol,
  39. // set xLocStI pointed to it, @include directive with this URL. If this script is Chrome extension, fill include_globs in manifest.json.
  40. // TODO If localStorage will be unavailable, script will be use next indexes of array.
  41. if (location.host == xLocSto[xLocStI].origin.replace(/[^/]*\/\//, "")) {
  42. window.addEventListener(
  43. "message",
  44. function (ev) {
  45. if (/^https?:\/\/www\.google\./.test(ev.origin)) {
  46. var d =
  47. typeof ev.data == "string" && ev.data[0] == "{"
  48. ? JSON.parse(ev.data)
  49. : ev.data;
  50. if (!d.do) return;
  51. var tok = d.tok,
  52. key = d.key;
  53. try {
  54. switch (d.do) {
  55. case "set":
  56. var prev = localStorage[key];
  57. if (d.val !== undefined)
  58. localStorage[key] = JSON.stringify(d.val);
  59. else localStorage.removeItem(key);
  60. break;
  61. case "get":
  62. prev = localStorage[key];
  63. prev =
  64. prev === undefined ||
  65. (typeof prev == "string" && prev[0] != "{")
  66. ? prev
  67. : JSON.parse(prev);
  68. break;
  69. case "remove":
  70. prev = localStorage[key];
  71. if (prev !== undefined) localStorage.removeItem(key);
  72. }
  73. } catch (er) { }
  74. //xLocStI !=0 && console.log('[xLocSto]', tok, 'prev=', prev);
  75. xLocStI != 0 &&
  76. ev.source.postMessage(
  77. JSON.stringify(
  78. prev !== undefined
  79. ? { tok: tok, prev: prev }
  80. : { tok: tok, undef: 1 }
  81. ),
  82. ev.origin
  83. );
  84. }
  85. },
  86. !1
  87. ); //console.log('[xLocSto-1]_'+ xLocStI);
  88. } else
  89. (function (setts) {
  90. //lang, sites, lastHoursLess
  91.  
  92. var $x = function (el, h) {
  93. if (h) for (var i in h) el[i] = h[i];
  94. return el;
  95. }, //===extend===
  96. $pd = function (ev) {
  97. ev.preventDefault();
  98. },
  99. d = document,
  100. $q = function (q, el) {
  101. return (el || d).querySelector(q);
  102. },
  103. lh = location.href,
  104. $e = function (g, el) {
  105. //===create or use existing element=== //g={el|clone,cl,ht,cs,at,atRemove,on,apT}
  106. g.el = el || g.el || g.clone || "DIV";
  107. var o = (g.o =
  108. (g.clone && g.clone.cloneNode && g.clone.cloneNode(!0)) ||
  109. (typeof g.el == "string" ? d.createElement(g.el) : g.el));
  110. if (o) {
  111. //execute if exist
  112. if (g.cl) o.className = g.cl;
  113. if (g.cs) $x(o.style, g.cs);
  114. if (g.ht || g.at) {
  115. var at = g.at || {};
  116. if (g.ht) at.innerHTML = g.ht;
  117. }
  118. if (at)
  119. for (var i in at) {
  120. if (i == "innerHTML") o[i] = at[i];
  121. else o.setAttribute(i, at[i]);
  122. }
  123. if (g.atRemove)
  124. for (var i in g.atRemove) o.removeAttribute(g.atRemove[i]);
  125. if (g.on)
  126. for (var i in g.on) if (g.on[i]) o.addEventListener(i, g.on[i], !1);
  127. g.ap && o.appendChild(g.ap);
  128. g.apT && g.apT.appendChild(o);
  129. }
  130. return o;
  131. },
  132. addRules = function (css) {
  133. $e(
  134. { apT: d.getElementsByTagName("head")[0], ap: d.createTextNode(css) },
  135. "style"
  136. );
  137. },
  138. //check occurrence of third-party event with growing interval: h.t=time, h.i=count, h.c=check, h.o=occur, h.m=multi
  139. CS = function (h, d) {
  140. d
  141. ? h.o(d)
  142. : h.i-- &&
  143. setTimeout(function () {
  144. CS(h, h.c());
  145. }, (h.t *= h.m));
  146. }, //example: t:120, i:12, m: 1.6 => wait around 55 sec
  147. //for xLocStor:
  148. xLocStorOrigin =
  149. d.location.protocol + xLocSto[xLocStI].origin.replace(/[^/]*/, ""),
  150. qr,
  151. qrs = {}, //set of queries "key-calls" (ок, toutLitt, toutLong, noService, noStorage)
  152. qrI = 0, //queries counter
  153. qrN = 12, //max number of waiting queries
  154. errIMax = 120,
  155. errNMax = errIMax, //max number of errors
  156. ns = "googXButtons_", //namespace for keys
  157. listenMsg,
  158. /**
  159. * external localStorage for using another domain if current domain storage is erased anywhere
  160. * @param{String} h.do - action: set|get|remove
  161. * @param{String} h.key
  162. * @param{Object|undefined} h.val (any type)
  163. * @param{Number|undefined} h.toutLitt
  164. * @param{Number|undefined} h.tout
  165. * @param{Function} h.cB - callback with 2 arguments
  166. * @param{Function|undefined} h.err - callback for err with one argument
  167. */
  168. xLocStor = function (h) {
  169. var h0 = h;
  170. h.toutLitt = h.toutLitt || 400;
  171. h.tout = h.tout || 4000;
  172. var ifr = d.getElementById("xLocStor"),
  173. query = function () {
  174. if ((qrI += 1) > qrN) {
  175. xCatch("longQrs", null, h);
  176. return;
  177. }
  178. ifr.contentWindow.postMessage(
  179. JSON.stringify(
  180. $x(
  181. {
  182. do: h.do,
  183. tok: token,
  184. key: ns + h.key,
  185. },
  186. h.val !== undefined ? { val: h.val } : {}
  187. )
  188. ),
  189. xLocStorOrigin
  190. );
  191. qrs[token] = $x(
  192. {
  193. //for wait of response
  194. wToutLitt: (function (h, qrI, errIMax) {
  195. return setTimeout(function () {
  196. qrI -= 1;
  197. if ((errIMax -= 1) >= 0); //console.warn('toutLitt', h);
  198. chkErrMax();
  199. }, h.toutLitt);
  200. })(h, qrI, errIMax),
  201. wTout: (function (h, qrI) {
  202. return setTimeout(function () {
  203. qrI -= 1;
  204. //xCatch('tout', null, h);
  205. //xLocStor(h0);
  206. }, h.tout);
  207. })(h, qrI),
  208. },
  209. h
  210. );
  211. },
  212. token = +new Date() + (Math.random() + "").substr(1, 8),
  213. el = h.el;
  214. delete h.el;
  215. if (ifr) query();
  216. else
  217. ifr = $e({
  218. el: "iframe",
  219. at: {
  220. id: "xLocStor",
  221. src: xLocStorOrigin + xLocSto[xLocStI].restHref,
  222. },
  223. cs: { display: "none" },
  224. on: { load: query },
  225. apT: el || d.body,
  226. });
  227. if (!listenMsg)
  228. addEventListener(
  229. "message",
  230. function (ev) {
  231. if (ev.origin == xLocStorOrigin) {
  232. // {"tok":"<value>"[,"err":"<txt>"],"h":...}
  233. //console.log('from_io', JSON.parse(ev.data))
  234. var resp = ev.data && ev.data[0] == "{" && JSON.parse(ev.data);
  235. if (!resp) xCatch("bad_format", resp, h);
  236. if ((qr = qrs[resp.tok])) {
  237. qrI -= 1;
  238. qr.cB(resp.prev, resp.undef);
  239. var er = qr.err;
  240. delete qrs[resp.tok];
  241. } // else ignore unsufficient token
  242. if (resp.err && (!er || er(resp.err)))
  243. //individual or common error processing depends of er()
  244. xCatch(resp.err, resp, h);
  245. }
  246. },
  247. !1
  248. );
  249. listenMsg = 1;
  250. },
  251. //for tests: localStorage.googXButtons_dwmyh = JSON.stringify({h:[1,2,1,1,1]})
  252. //$('#xLocStor').contentWindow.postMessage('{"do":"get","key":"googXButtons_dwmyh"}',xLocSto[xLocStI].origin)
  253. xCatch = function (er, resp, h) {
  254. if ((errIMax -= 1) >= 0)
  255. console.error(
  256. "tok:",
  257. (resp && resp.tok) || "--",
  258. "; err:",
  259. er,
  260. "; h:",
  261. h,
  262. "; respH:",
  263. resp && resp.h
  264. );
  265. chkErrMax();
  266. },
  267. chkErrMax = function () {
  268. if (!errIMax) console.error("Too many err messages:", errNMax);
  269. },
  270. fileType = "PDF,DOC,RTF,ODF,XLS,ODS,PPT,ODP,TXT,XML,More..., KML,DWF,PS,WPM,BAS,C,CC,CPP,CXX, Java,PL,PY,H,HPP,CS"
  271. .split(/,\s*/)
  272. .map(function (x) {
  273. return "&nbsp;" + x + "&nbsp; ";
  274. }),
  275. isFTMore = 0,
  276. meta = {
  277. Goog: "",
  278. Duck: "",
  279. Bing: "",
  280. Ask: "",
  281. Baidu: "",
  282. Yandex: "",
  283. Mailru: "",
  284. SlideS: "",
  285. }, //will create child-tabs (window names)
  286. imgFile = "SVG,JPG,GIF,PNG,BMP,webp,ICO,RAW".split(",").map(function (x) {
  287. return "&nbsp;" + x + "&nbsp; ";
  288. }), //will switch to Img Search
  289. imgType = "face,clipart,photo,lineart,animated".split(","), //for Img Search (+imgColor,imgSize,imgSizeLt)
  290. imgColor = "red,orange,yellow,green,teal,blue,purple,pink,white,gray,black,brown".split(
  291. ","
  292. ),
  293. imgSize = "l,m,small,icon,>=,Exact...".split(","),
  294. imgSizeLt = "vga,svga,xga,2mp,4mp,qsvga".split(","),
  295. $l = {
  296. ru: {
  297. "search in PDF files": "поиск по документам PDF",
  298. "search in": "искать по",
  299. More: "Ещё",
  300. "search black/white": "искать чёрно-белые",
  301. "return to colored": "вернуться к цветным",
  302. "from / to": "за период",
  303. past: ["за последний", "за последние", "за последнюю"],
  304. day: "сутки",
  305. days: ["дня", "дней"],
  306. week: "неделю",
  307. weeks: ["недели", "недель"],
  308. month: "месяц",
  309. months: ["месяца", "месяцев"],
  310. year: "год",
  311. years: ["года", "лет"],
  312. hour: "час",
  313. hours: ["часа", "часов"],
  314. Settings: "Настройки",
  315. "of userscript": "юзерскрипта",
  316. "reload page for effect": "перезагрузить страницу",
  317. "Interface language": "Язык интерфейса",
  318. "Less positions at the end of selects":
  319. "Меньше выбора в конце селектов",
  320. "Gray design of buttons": "Серый дизайн кнопок",
  321. "Show Filetype Button": "Кнопка типов файлов",
  322. Sites: "Сайты",
  323. },
  324. fr: {
  325. "search in PDF files": "la recherche dans les fichiers PDF",
  326. "search in": "rechercher dans",
  327. More: "Plus",
  328. "search black/white": "trouver noir et blanc",
  329. "return to colored": "retour à la couleur",
  330. "from / to": "pour la période",
  331. past: ["le dernier", "dans les derniers", "dans les derniers"],
  332. day: "jour",
  333. days: ["jours", "jours"],
  334. week: "semaine",
  335. weeks: ["semaines", "semaines"],
  336. month: "mois",
  337. months: ["mois", "mois"],
  338. year: "an",
  339. years: ["ans", "ans"],
  340. hour: "heure",
  341. hours: ["heures", "heures"],
  342. Settings: "Paramètres",
  343. "of userscript": "de Userscript",
  344. "reload page for effect": "recharger la page pour effet",
  345. "Interface language": "Langue de l'interface",
  346. "Less positions at the end of selects":
  347. "Moins de choix les longues listes",
  348. "Gray design of buttons": "Gris design des boutons",
  349. "Show Filetype Button": "Bouton Types de fichiers",
  350. Sites: "Les sites",
  351. },
  352. de: {
  353. "search in PDF files": "Suche in PDF-Dateien",
  354. "search in": "Suche in",
  355. More: "Mehr",
  356. "search black/white": "schwarz und weiß finden",
  357. "return to colored": "zurück zur Farbe",
  358. "from / to": "im Zeitraum",
  359. past: ["letzte", "letzte", "letzte"],
  360. day: "Tag",
  361. days: ["Tage", "Tage"],
  362. week: "Woche",
  363. weeks: ["Wochen", "Wochen"],
  364. month: "Monat",
  365. months: ["Monate", "Monate"],
  366. year: "Jahr",
  367. years: ["Jahre", "Jahre"],
  368. hour: "Stunde",
  369. hours: ["Stunden", "Stunden"],
  370. Settings: "Einstellungen",
  371. "of userscript": "von Userscript",
  372. "reload page for effect": "Seite neu laden",
  373. "Interface language": "Sprache",
  374. "Less positions at the end of selects":
  375. "Weniger Auswahl in langen Listen",
  376. "Gray design of buttons": "Graues Design der Schaltflächen",
  377. "Show Filetype Button": "Schaltfläche Dateitypen",
  378. Sites: "Websites",
  379. },
  380. es: {
  381. "search in PDF files": "búsqueda en archivos PDF",
  382. "search in": "busca en",
  383. More: "Más",
  384. "search black/white": "encontrar blanco y negro",
  385. "return to colored": "volver al color",
  386. "from / to": "para el período",
  387. past: ["el último", "en los últimos", "en los últimos"],
  388. day: "día",
  389. days: ["días", "días"],
  390. week: "Semana",
  391. weeks: ["semanas", "semanas"],
  392. month: "mes",
  393. months: ["meses", "meses"],
  394. year: "año",
  395. years: ["años", "años"],
  396. hour: "hora",
  397. hours: ["horas", "horas"],
  398. Settings: "Ajustes",
  399. "of userscript": "de userscript",
  400. "reload page for effect": "página para efecto de recargar",
  401. "Interface language": "Idioma de interfaz",
  402. "Less positions at the end of selects":
  403. "Menos elección en listas largas",
  404. "Gray design of buttons": "Diseño gris de botones",
  405. "Show Filetype Button": "Botón de tipos de archivo",
  406. Sites: "Sitios",
  407. },
  408. },
  409. cB; //if !lang, then no hints
  410. var bBack = /^(?:rgba?\((\d+)|#(.))/.exec(
  411. window.getComputedStyle(d.body).backgroundColor.replace(/gb/, "gba")
  412. ), // for Images tab
  413. mDark =
  414. (d.querySelectorAll('meta[name="color-scheme"]')[0] || {}).content ===
  415. "dark" ||
  416. (bBack && ((bBack[1] && bBack[1] < 96) || (bBack[2] && bBack[2] < 6)));
  417. addRules(
  418. ".hp .sfsbc,.sfsbc{display:inline-block}.siteList:hover button{display:block}" +
  419. ".gb_Ib >.gb_e{height:47px}.gb_Fb{z-index:1087}.tsf-p{z-index:203}" +
  420. ".lsbb .xButt,.lsbb >.siteList,.sbibod .xButt,.sbibod >.siteList {z-index:2002; width:34px; height:17px;" +
  421. "padding:0 2px; line-height:14px; font-size:14px; border:1px solid transparent; border-radius:2px;" +
  422. "background-color:#dddae6; color:#eee; opacity:.07; transition:opacity .57s ease-in}" +
  423. ".lsbb >.siteList:hover {background-color:#4889f1}" +
  424. ".lsbb >.siteList,.sbibod >.siteList {width:32px; height:auto; padding:1px 0 2px; text-align:center}" +
  425. ".lsbb >.siteList .lsb >.txt.or {visibility:hidden; position:relative; left:3px; top:-2px; margin-left:-14px;" +
  426. "font-size:9px; font-variant:small-caps; border:1px solid rgb(72, 137, 241); border-radius:8px;" +
  427. "background-color:rgba(233, 238, 247, 0.66); color:rgb(131, 105, 68)}.lsbb >.siteList .lsb >.txt.or.sit {left:-1px}" +
  428. ".lsbb >.siteList .selted .lsb:not(.more):not(.moreShow):not(.sett):hover >.txt.or {visibility:visible}" +
  429. //deprecated gray design
  430. ".lsbb .xButt:hover,.sbibod .xButt:hover,.xButt.xButt2:hover .xButt2,.xButt2:hover{background-color:#c3d4e1; color:#fff; opacity:1}" +
  431. ".xButt2{padding:0 0 2px; background-color:#dad6e2; color:#eee; opacity:1}" +
  432. ".sbibod.lsbb{height:44px}" +
  433. ".sbibod .xButt:hover,.sbibod .xButt2:hover,.sbibod .xButt:hover .xButt2{background-color:#c3c6c7}" +
  434. ".sbibod:not(.lsbb) >.siteList, .sbibod:not(.lsbb) >.xButt2{background-color:#dddae6; opacity:.45}" +
  435. ".sbibod:not(.lsbb) >.siteList:hover, .sbibod:not(.lsbb) >.xButt2:hover{background-color:#dddae6; opacity:.87}" +
  436. ".sbibod >.siteList >.list{background-color:#e1deeb}" +
  437. ".sbibod >.siteList.fade:hover{opacity:1; transition:opacity .1s ease-in}" +
  438. ".sbibod >.siteList.fade{opacity:0.23}" +
  439. ".list .more ~.xButt{display:none!important}" +
  440. ".list .moreShow ~ .xButt{position:absolute!important; left:52px; height:19px!important}" +
  441. ".list .moreShow~.x2.xButt, .list .moreShow~.x2 ~.xButt{left:99px}" +
  442. ".siteList .sett .txt{padding:2px 2px 4px; font-size:14px}" +
  443. ".siteList .settIn{display:none; width:250px; padding:2px 4px; text-align:left; border:1px solid #48f; font-size:14px;" +
  444. "background-color:#dde; color:#336}" +
  445. ".siteList .settIn hr{margin:2px 0}" +
  446. ".sbibtd .sfsbc .nojsb, .siteList .sett:hover .settIn, .siteList .settIn.changed," +
  447. ".siteList .settIn.changed .reload{display:block}.siteList .settIn .reload, .siteList.hiddn{display:none}" +
  448. 'div.gb_g[aria-label="promo"],.pdp-psy.og-pdp, .gb_Sc.gb_g .gb_ha, .gb_g.gb_ha:not(.xpdopen ){display:none}' +
  449. ".xpdopen{display:block!important}.rhsvw{opacity:.16; transition:.4s}.rhsvw:hover{opacity:1}" +
  450. ".srp #sfdiv{overflow:inherit}" + //hide promo
  451. ".UUbT9 >div.aajZCb{background-color:rgba(" +
  452. (mDark ? "40,44,48, 0.92" : "255,255,255, 0.75") +
  453. ");}" + //opacity for suggests
  454. ".UUbT9 ul li div span b{background-color:rgba(" +
  455. (mDark ? "88,93,99" : "237,242,248") +
  456. ", 0.9); margin:0 -6px 0 4px; padding:0 6px 0 0;border-radius:7px;}" + //white under suggest texts
  457. ".gb_kb{padding-left:10px; padding-right:7px}form .RNNXgb{position:relative; background:rgba(" +
  458. (mDark ? "40,44,48" : "255,255,255") +
  459. ", 0.92)}" +
  460. ".RNNXgb, #tsf{width:auto!important} #searchform form#tsf{max-width:auto} body div#searchform,body .ctr-p{min-width:0}" +
  461. "div#searchform.minidiv{top:-8px!important}.minidiv .sfbg{margin-top:-26px!important}" + // for narrow sticked searchbar
  462. ".minidiv .sfbg{top:-39px}.minidiv .sfbg +form#tsf{top:-39px}.minidiv .sfbg +form#tsf:hover{top:0}" + //hide sticked
  463. ".minidiv .sfbg +form#tsf:hover .siteList, .minidiv .sfbg +form#tsf:hover .lsbb >.xButt {top:-6px!important}" +
  464. ".RNNXgb .Tg7LZd {flex:0 0 auto; visibility:hidden; width:44px; height:44px; margin-right:-31px; padding:0 13px 0 0;" +
  465. " border-radius:0 8px 8px 0; background:transparent; border:none; outline:none}" +
  466. ".emcav div.RNNXgb {z-index:998; box-shadow:0 -1px 4px 0 rgba(32,33,36,0.28)}" +
  467. ".minidiv .RNNXgb {z-index:998}.minidiv .RNNXgb:hover {box-shadow:0 -1px 4px 0 rgba(32,33,36,0.28)}" +
  468. ".A8SBwf .logo +.RNNXgb .Tg7LZd {visibility:visible; margin-right:-9px; margin-bottom:-2px; transition:margin 5s ease-in-out}"
  469. );
  470. try {
  471. xLocStor({
  472. do: "get",
  473. key: "sett",
  474. val: setts,
  475. cB: (cB = function (prev, undef) {
  476. S = prev || setts;
  477. S.dwmyh = S.dwmyh || setts.dwmyh; //temp. transitional expr.
  478. console.timeStamp = function () { };
  479. addRules(
  480. !(S.whiteMintOval || S.whiteMintOval === undefined) //blue old design
  481. ? ".lsbb .xButt:not(.xButt2),.lsbb >.siteList,.sbibod .xButt:not(.xButt2) {text-align:center; background-color:#4889f1; color:#fff; opacity:0.75}" +
  482. ".lsbb >.siteList .lsb,.sbibod >.siteList .lsb {font-weight:normal; color:#d4d4d4}" +
  483. ".lsbb .lsb:hover,.sbibod .lsb:hover {opacity:1; color:#f1c44a; cursor:default}" +
  484. ".lsbb >.siteList >div:not([class]):hover,.sbibod >.siteList:hover {background-color:#c2d4e0; color:#f7f7f7; opacity:.93}" +
  485. ".lsbb >.siteList >div:not([class]):hover span {color:#aa6c1c}" +
  486. ".lsbb >.siteList .sett .txt{background-color:#4889f1}"
  487. : //white-mint-oval design
  488. ".lsbb .xButt:not(.xButt2), .lsbb >.siteList {text-align:center; background-color:rgb(" +
  489. (mDark ? "92,100,110" : "240,247,248") +
  490. "); opacity:0.75; color:rgb(" +
  491. (mDark ? "40,44,48" : "137,137,137") +
  492. ")}" +
  493. ".lsbb >.siteList {border:1px solid rgb(" +
  494. (mDark ? "87,97,108" : "183,219,205") +
  495. "); border-radius:10px; background-color:rgba(" +
  496. (mDark ? "86,89,92" : "243,243,243") +
  497. ",0.7); color:rgb(" +
  498. (mDark ? "140,154,173" : "75,143,231") +
  499. ")}" +
  500. ".lsbb >.siteList .lsb {font-weight:normal; border:1px solid rgb(" +
  501. (mDark ? "98,98,90" : "210,210,190") +
  502. "); border-radius:10px; background-color:rgb(" +
  503. (mDark ? "77,84,89" : "225,239,239") +
  504. "); color:rgb(140, 140, 140)}" +
  505. ".lsbb .lsb:hover {opacity:1; color:rgb(152, 123, 43); cursor:default}" +
  506. ".lsbb >.siteList:hover {background-color:rgb(" +
  507. (mDark ? "87,97,108" : "183,219,205") +
  508. ")}" +
  509. ".lsbb .xButt:hover {background-color:rgb(221, 230, 228)}" +
  510. ".lsbb >.siteList >div:not([class]):hover span {color:rgb(" +
  511. (mDark ? "233,140,19" : "170,108,28") +
  512. ")}" +
  513. ".lsbb >.siteList .sett .txt {position:relative; top:2px; margin:0 -2px; padding:1px;" +
  514. "border:1px solid rgb(" +
  515. (mDark ? "87,97,108" : "183,219,205") +
  516. "); border-radius:10px; background-color:rgb(" +
  517. (mDark ? "92,100,110" : "240,247,248") +
  518. ")"
  519. );
  520. CS({
  521. t: 120,
  522. i: 12,
  523. m: 1.6,
  524. c: function () {
  525. return (
  526. d &&
  527. d.getElementsByName("q") &&
  528. !/[?&]tbm=(shop|bks|fin)/.test(lh) &&
  529. d.getElementsByName("q")[0]
  530. );
  531. },
  532. o: function (dat) {
  533. var lang = S.lang != null ? S.lang : setts.lang,
  534. sites =
  535. (S.sites &&
  536. ((S.sites.length && S.sites[0]) || S.sites.length > 1) &&
  537. S.sites) ||
  538. (typeof sites == "string" && [sites]) ||
  539. (!S.sites && setts.sites) ||
  540. null;
  541. var strSites =
  542. (sites && sites.join("\n").replace(/^\n/, "\n\n")) || "",
  543. $L = $l[lang] || $l.ru; //default template of lang
  544. if (!lang || !$l[lang] || lang == "en")
  545. for (var l in $L) {
  546. //replace 'en' lang for default or substitution
  547. if ($L[l] instanceof Array)
  548. for (var l2 in $L[l]) $L[l][l2] = l;
  549. else $L[l] = l;
  550. }
  551. var srch = $q(".RNNXgb"),
  552. startPg =
  553. (srch && !$q("button", srch)) || /\/(web|img)hp/.test(lh);
  554. if (startPg) {
  555. //console.log('==-==startPg', srch);
  556. $e({
  557. el: "button",
  558. cl: "Tg7LZd",
  559. at: {
  560. "aria-label": "Google Search",
  561. type: "button",
  562. jsname: "Tg7LZd",
  563. innerHTML:
  564. '<div class="gBCQ5d"><span class="z1asCe MZy1Rb">sr</span></div>',
  565. },
  566. apT: srch,
  567. });
  568. }
  569. var $LSettings = $L["Settings"];
  570. if (sites && sites.length) sites.push($LSettings);
  571. var mainPg = /\/search\?|&q=|#q=/.test(lh),
  572. inputSearch = dat,
  573. layout1811 =
  574. $q(".Tg7LZd") ||
  575. $q('button[aria-label="Google Search"]') ||
  576. $q('button[jsname="Tg7LZd"]'),
  577. design1612 = ($q("#_fZl") || $q(".sbico-c")) && !layout1811,
  578. d16 = (design1612 || layout1811) && S.design1612,
  579. imSrch = /[?&]tbm=isch|\/imghp/.test(lh), // sizes are shown if images (outdated): /[&?]tbs[^&]*?(=|,|%2C)imgo(:|%3A)1/i
  580. imgTools = imSrch && /[&?]tbs=[^&]*/.exec(lh), //'tbs' with all params
  581. isBWShown =
  582. imgTools && /[&?]tbs[^&]*?(=|,|%2C)ic(:|%3A)gray/i.exec(lh), // Black-White Images search
  583. buttSearcStart =
  584. (startPg &&
  585. layout1811 &&
  586. ($q('input[name="btnK"]') ||
  587. $q('input[aria-label="Google Search"]'))) ||
  588. $q('button[jsname="Tg7LZd"]'), //for the start page
  589. buttSearch =
  590. (d.getElementsByName("btnG") &&
  591. d.getElementsByName("btnG")[0]) ||
  592. design1612 ||
  593. layout1811,
  594. buttS = {
  595. Srch: { url: "", txt: "search" },
  596. PDF: {
  597. url: "filetype:PDF",
  598. txt:
  599. $L[
  600. imSrch
  601. ? (isBWShown ? "hide" : "show") + " sizes"
  602. : "search in PDF files"
  603. ],
  604. },
  605. site: {
  606. url: "site:" + S.sites[0],
  607. txt: $L["search in"] + " " + S.sites[0],
  608. one: "day",
  609. }, //you may comment this line
  610. //,'.. : ..':{url:'', txt:$L['from / to']}
  611. "1D": {
  612. url: "&tbs=qdr:d",
  613. txt: $L["past"][1] + " " + $L["day"],
  614. one: "day",
  615. up: 13,
  616. lett: "D",
  617. },
  618. "1W": {
  619. url: "&tbs=qdr:w",
  620. txt: $L["past"][2] + " " + $L["week"],
  621. one: "week",
  622. up: 14,
  623. lett: "W",
  624. },
  625. "1M": {
  626. url: "&tbs=qdr:m",
  627. txt: $L["past"][0] + " " + $L["month"],
  628. one: "month",
  629. up: 20,
  630. lett: "M",
  631. },
  632. "1Y": {
  633. url: "&tbs=qdr:y",
  634. txt: $L["past"][0] + " " + $L["year"],
  635. one: "year",
  636. up: 15,
  637. lett: "Y",
  638. },
  639. "1H": {
  640. url: "&tbs=qdr:h",
  641. txt: $L["past"][0] + " " + $L["hour"],
  642. one: "hour",
  643. up: 23,
  644. lett: "H",
  645. },
  646. },
  647. ii = -1,
  648. iD = -1;
  649. if (
  650. (design1612 || layout1811) &&
  651. !d16 &&
  652. buttSearch &&
  653. buttSearch.parentNode
  654. )
  655. buttSearch.parentNode.className += " lsbb";
  656. !sites && delete buttS.site;
  657. if (!layout1811 && buttSearch && buttSearch.parentNode) {
  658. buttSearch.parentNode.style.position = "relative";
  659. buttSearch.parentNode.style.zIndex = "1003";
  660. }
  661. if (buttSearch && top == self)
  662. for (var i in buttS)
  663. if ((i == "site" && !S.sites) || !imSrch || i != "1H") {
  664. ++ii; //buttons under search input line
  665. if (i.length == 2) iD++;
  666. else iD = -1;
  667. var bI = buttS[i],
  668. Gesch = { m: "letzter", f: "letzte", n: "letztes" }[
  669. "m,f,m,n,f".split(",")[iD]
  670. ],
  671. hint = function (j) {
  672. return (
  673. j +
  674. 1 +
  675. " " +
  676. (j % 10 || j == 10
  677. ? $L[bI.one + "s"][
  678. j % 10 < 4 && ((j / 10) | 0) != 1 ? 0 : 1
  679. ]
  680. : $L[bI.one])
  681. );
  682. },
  683. // 🕮 <lunde> ef3c5f9a-82e1-4b71-9a8d-7c902e27927b.md
  684. csLeft = function (ii) {
  685. let calculatedPosition = BASE_POSITION + BUTTON_SPACING * (ii - 1);
  686. return design1612 || layout1811
  687. ? { right: -calculatedPosition - RIGHT_OFFSET + "px" }
  688. : { left: calculatedPosition + "px" };
  689. },
  690. isBWShown2 = isBWShown && i == "PDF",
  691. butt2 = $e({
  692. clone:
  693. i == "site" || i.length == 2 || i == "PDF"
  694. ? $e({
  695. cl: "siteList",
  696. cs: { cursor: "default" },
  697. at: { site: S.sites[0], date: bI.url },
  698. })
  699. : i != ".. : .." || mainPg
  700. ? $e({
  701. el: "button",
  702. cl: "xButt " + (d16 ? "xButt2" : "lsb"),
  703. })
  704. : $e({ cl: "siteList hiddn" }),
  705. at: {
  706. value:
  707. iD != -1 && S.dwmyh[iD] != 1
  708. ? S.dwmyh[iD] + bI.lett
  709. : i,
  710. innerHTML:
  711. "<div" +
  712. (d16 ? " class=xButt2" : "") +
  713. "><s" +
  714. (isBWShown2 ? "" : "pan") +
  715. ' class=txt onclick=this.parentNode.click();return!1 title="' +
  716. (lang || i == "site" || i == ".. : .."
  717. ? (
  718. (iD == -1 || S.dwmyh[iD] == 1
  719. ? bI.txt
  720. : $L["past"][1] +
  721. " " +
  722. hint(S.dwmyh[iD] - 1)) || ""
  723. ).replace(/letzte/, Gesch)
  724. : "") +
  725. '" itrvNum="' +
  726. (i == "site"
  727. ? ""
  728. : bI.url + (imSrch ? "" : S.dwmyh[iD])) +
  729. '">' +
  730. (iD != -1 && S.dwmyh[iD] != 1
  731. ? S.dwmyh[iD] + bI.lett
  732. : imSrch && i == "PDF"
  733. ? "B/W"
  734. : i) +
  735. (isBWShown2 ? "</s>" : "</span>") +
  736. "</div>",
  737. },
  738. cs: $x(
  739. {
  740. position: "absolute",
  741. top: startPg ? "40px" : "33px",
  742. wordSpacing: "-1px",
  743. visibility:
  744. ii <= S.hiddenEdgeLeft ? "hidden" : "visible",
  745. },
  746. $x(
  747. csLeft(ii),
  748. ii === 2
  749. ? {
  750. width: "26px",
  751. marginRight: "3px",
  752. borderRadius: "2px",
  753. lineHeight: "0.75em",
  754. marginTop: "0.125em",
  755. }
  756. : {}
  757. )
  758. ),
  759. on: {
  760. click: (function (bI, i, iD) {
  761. //console.log('clic0:', i, iD);
  762. return /Srch|PDF|DOC|site/.test(i)
  763. ? function (ev) {
  764. var t = ev.target;
  765. //console.log('cli-DocSite: i,t.class,value,ev,attrSite,$LS,aPSite,bSSta',i, t.className, inputSearch.value,ev, 'attrSite:'
  766. // ,t.getAttribute('site'),'aP:', t.parentNode.getAttribute('site'), buttSearcStart);
  767. if (t && t.className == "defa")
  768. saveLocStor("", "", "remove");
  769. $pd(ev);
  770. if (
  771. t &&
  772. (t.getAttribute("site") == $LSettings ||
  773. (t.parentNode &&
  774. t.parentNode.getAttribute("site") ==
  775. $LSettings)) &&
  776. !/Srch|PDF|DOC/.test(i)
  777. )
  778. return;
  779. if (
  780. t.classList.contains("settIn") ||
  781. t.parentNode.classList.contains("settIn")
  782. ) {
  783. ev.stopPropagation();
  784. return;
  785. }
  786. if (t && t.className != "txt")
  787. inputSearch.value =
  788. (inputSearch.value || "")
  789. .replace(
  790. /( site(:|%3A)\s*\S*|$)/gi,
  791. /Srch|site/.test(i) ? "" : "$1"
  792. )
  793. .replace(
  794. /( |\+|&as_)filetype(:|%3A)[^\&]*/g,
  795. ""
  796. ) +
  797. " " +
  798. (/Srch|PDF|DOC/.test(i)
  799. ? imSrch
  800. ? ""
  801. : bI.url
  802. : "site:" +
  803. ((t &&
  804. (t.getAttribute("site") ||
  805. (t.parentNode &&
  806. t.parentNode.getAttribute(
  807. "site"
  808. )))) ||
  809. ""));
  810. if (
  811. t &&
  812. t.getAttribute("site") == null &&
  813. t.parentNode &&
  814. t.parentNode.getAttribute("site") == null &&
  815. !/Srch|PDF|DOC/.test(i)
  816. )
  817. return;
  818. if (imSrch && i == "PDF") {
  819. ev.stopPropagation();
  820. saveLocStor();
  821. location.href = isBWShown
  822. ? lh.replace(
  823. new RegExp(imgTools[0]),
  824. imgTools &&
  825. imgTools[0]
  826. .replace(
  827. /(,|%2C)?ic(:|%3A)gray/gi,
  828. ""
  829. )
  830. .replace(
  831. /([?&])tbs=?,?(&|$)/,
  832. "$1"
  833. )
  834. ) //return to colored
  835. : imgTools
  836. ? imgTools &&
  837. lh.replace(
  838. new RegExp(imgTools[0]),
  839. imgTools[0] +
  840. (imgTools[0].length < 5
  841. ? ""
  842. : ",") +
  843. "ic:gray"
  844. ) //upd.'Show'
  845. : lh +
  846. (/\?/.test(lh) ? "&" : "?") +
  847. "tbs=ic:gray"; //new Tools-More_tools_Show_sizes
  848. } else if (
  849. (t &&
  850. /xButt|txt/.test(t.className) &&
  851. !(
  852. i == "site" &&
  853. !(
  854. /list/.test(t.parentNode.className) ||
  855. /list/.test(
  856. t.parentNode.parentNode.className
  857. )
  858. )
  859. )) ||
  860. (t && /Srch|PDF|DOC/.test(t.value))
  861. )
  862. /*console.log('==startSrch'),*/ (
  863. buttSearcStart || buttSearch
  864. ).click();
  865. }
  866. : !bI.url
  867. ? function (ev) {
  868. //from-to date (! not used now)
  869. var el = $q("#cdrlnk"),
  870. o;
  871. el &&
  872. el.dispatchEvent(
  873. ((o = d.createEvent("Events")).initEvent(
  874. "click",
  875. !0,
  876. !1
  877. ),
  878. o)
  879. );
  880. $pd(ev);
  881. }
  882. : function (ev) {
  883. //past interval
  884. var t = ev && ev.target,
  885. sbd = /,sbd:1/.test(lh),
  886. ta = t,
  887. tOvr = t && t.parentNode,
  888. tOv0 = tOvr,
  889. date2 = tOvr && tOvr.getAttribute("date");
  890. var l2 = startPg
  891. ? lh.replace(
  892. /^([^/]*)\/\/([^/]+)\/?([^?#]*)([?#]?.*)/,
  893. "$1//$2/search$4"
  894. )
  895. : lh; // insert '/search?' instead any
  896. //console.log('cli-Past: value,date2,siteList,list,l2',inputSearch.value,date2,tOvr.classList.contains('siteList'), t.classList.contains('list'), l2);
  897. if (
  898. tOvr &&
  899. tOvr.classList.contains("siteList") &&
  900. !ta.classList.contains("list")
  901. ) {
  902. //clicked by top button
  903. var elTop =
  904. $q("div:not(.list) >.txt", tOvr) || "",
  905. itrvNum =
  906. (elTop &&
  907. elTop.getAttribute("itrvNum")) ||
  908. "",
  909. newSrch = /[?&]q=/.test(l2)
  910. ? l2.replace(
  911. /(&|\?)q=([^&]*)(&|$)/g,
  912. "$1q=" +
  913. encodeURIComponent(
  914. inputSearch.value
  915. ) +
  916. "$3"
  917. ) //add value to '[?&]q=[^&]*'
  918. : l2 +
  919. (/\?/.test(l2) ? "&" : "?") +
  920. "q=" +
  921. encodeURIComponent(inputSearch.value); //set new value as &q=.+
  922. if (layout1811 && itrvNum !== "" && date2)
  923. location.href = /qdr(:|%3A)([dwmyh])\d*/.test(
  924. l2
  925. )
  926. ? newSrch.replace(
  927. /([?&]tbs=)?qdr(:|%3A)[dwmyh]\d*/,
  928. function (x) {
  929. return itrvNum.replace(
  930. /&/,
  931. /\?/.test(x) ? "?" : "&"
  932. );
  933. }
  934. ) //patch date in URL
  935. : newSrch +
  936. (/\?/.test(newSrch) ? "&" : "?") +
  937. itrvNum; //add date in URL
  938. if (itrvNum != null)
  939. S.dwmyh[iD] = +(itrvNum || "").replace(
  940. /\D/g,
  941. ""
  942. );
  943. } else if (
  944. t.textContent ||
  945. tOv0.textContent
  946. ) {
  947. var sa = (
  948. t.textContent ||
  949. tOv0.textContent ||
  950. ""
  951. ).replace(/\D/g, "");
  952. if (sa.length <= 6) S.dwmyh[iD] = +sa;
  953. }
  954. //console.log('==noDocNoSite', tOvr.value, itrvNum);
  955. $pd(ev);
  956. ev.stopPropagation();
  957. saveLocStor();
  958. };
  959. })(bI, i, iD),
  960. mouseover:
  961. i == "site" || i.length == 2 || i == "PDF"
  962. ? (function (bI, i) {
  963. return function (ev) {
  964. clearTimeout(bI.ww);
  965. var t = ev.currentTarget;
  966. t.classList.add("fade");
  967. $q(".list", t).style.display = "block";
  968. };
  969. })(bI, i)
  970. : "",
  971. mouseout:
  972. i == "site" || i.length == 2 || i == "PDF"
  973. ? (function (bI, i) {
  974. return function (ev) {
  975. var t = ev.currentTarget;
  976. clearTimeout(bI.ww);
  977. bI.ww = setTimeout(function () {
  978. $q(".list", t).style.display = "none";
  979. t.classList.remove("fade");
  980. }, 570);
  981. };
  982. })(bI, i)
  983. : "",
  984. change: saveLocStor,
  985. },
  986. apT: buttSearch.parentNode,
  987. });
  988. bI.el = butt2;
  989. if (i == "site" || i.length == 2 || i == "PDF") {
  990. //dropdown lists under some buttons
  991. //TODO 'list selted' will be placed if search by filetype or by site was presented (and accordingly buttons will be with 'selted')
  992. var siteList = $e({
  993. cl: "list",
  994. cs: { display: "none" },
  995. apT: butt2,
  996. }),
  997. arr = [];
  998. for (
  999. var j = 0;
  1000. j <
  1001. (imSrch
  1002. ? 1
  1003. : bI.up -
  1004. (i == "1W" && S.lastHoursLess ? 4 : 0) -
  1005. (i == "1M" && S.lastHoursLess ? 9 : 0) -
  1006. (i == "1Y" && S.lastHoursLess ? 5 : 0));
  1007. j++
  1008. )
  1009. if (i != "1H" || !S.lastHoursLess || j < 8 || j % 2)
  1010. arr.push(hint(j));
  1011. //console.log(S.sites,i, S.dwmyh);
  1012. var list =
  1013. i == "site"
  1014. ? sites || []
  1015. : i == "1D" && !sites
  1016. ? arr.concat([$LSettings])
  1017. : i == "PDF"
  1018. ? imSrch
  1019. ? imgFile
  1020. : fileType
  1021. : arr,
  1022. fTMoreX2 = 0;
  1023. for (var j in list)
  1024. if (j != 0 || (iD != -1 && S.dwmyh[iD] != 1)) {
  1025. //console.log('==i,sI', i, sI);
  1026. fTMoreX2 = /CPP/.test(fTyp) || fTMoreX2;
  1027. var sI = list[j],
  1028. fTyp = sI.replace(/&nbsp; ?/g, ""),
  1029. fTMore = /More\.\.\./.test(fTyp),
  1030. butt3 = $e({
  1031. clone:
  1032. sI == $LSettings
  1033. ? $e({
  1034. cl:
  1035. "sett" +
  1036. (d16 ? " xButt xButt2" : " lsb"),
  1037. })
  1038. : $e({
  1039. el: "button",
  1040. cl:
  1041. "xButt" +
  1042. (d16 ? " xButt2" : " lsb") +
  1043. (fTMore ? " more" : "") +
  1044. (fTMoreX2 ? " x2" : ""),
  1045. }),
  1046. at: {
  1047. value: sI,
  1048. site: sI,
  1049. date: bI.url.replace(/pdf$/i, fTyp),
  1050. title:
  1051. sI == $LSettings || !lang
  1052. ? ""
  1053. : (/site|PDF/.test(i)
  1054. ? (
  1055. $L[
  1056. i == "PDF"
  1057. ? "search in PDF files"
  1058. : "search in"
  1059. ] + (i == "PDF" ? "" : " " + sI)
  1060. ).replace(/PDF/, fTyp)
  1061. : j == 0
  1062. ? bI.txt
  1063. : $L["past"][1] + " " + sI
  1064. ).replace(/letzte/, Gesch),
  1065. innerHTML:
  1066. (/site|PDF/.test(i)
  1067. ? '<span class="txt or' +
  1068. (i == "PDF" ? "" : " sit") +
  1069. '" data-val="' +
  1070. sI.replace(/&nbsp; ?/g, "") +
  1071. '" title="' + //multiselect mechanics
  1072. (1
  1073. ? (i == "PDF" ? "" : "sites ") +
  1074. "multiselect" +
  1075. (i == "PDF" ? " of types" : "")
  1076. : "click to disable select") +
  1077. '">' +
  1078. (1 ? "OR" : "V") +
  1079. "</span>"
  1080. : "") +
  1081. "<span class=txt>" +
  1082. sI +
  1083. "</span>" +
  1084. (sI != $LSettings && !(!S.sites && i == "1H")
  1085. ? ""
  1086. : '<div class="settIn">' +
  1087. $L.Settings +
  1088. " " +
  1089. $L["of userscript"] +
  1090. '<br/>"Google Search Extra Buttons"<hr/>' +
  1091. $L["Interface language"] +
  1092. ': <select class="lang" style="width:70px">' +
  1093. (function () {
  1094. var s =
  1095. "<option" +
  1096. (lang == "en" ? " selected" : "") +
  1097. ">en</option>";
  1098. for (var i in $l)
  1099. s +=
  1100. "<option" +
  1101. (lang == i ? " selected" : "") +
  1102. ">" +
  1103. i +
  1104. "</option>";
  1105. return (
  1106. s +
  1107. '<option value=""' +
  1108. (lang == "" ? " selected" : "") +
  1109. ">en w/o hints</option>"
  1110. );
  1111. })() +
  1112. "</select><br/>" +
  1113. '<input type="checkbox" class="less" id="hoursLess"' +
  1114. (S.lastHoursLess ? " checked" : "") +
  1115. "/>" +
  1116. '<label for="hoursLess" id="hoursLessL">' +
  1117. $L[
  1118. "Less positions at the end of selects"
  1119. ] +
  1120. "</label><br/>" +
  1121. '<input type="checkbox" class="des16" id="design1612"' +
  1122. /*!layout1811 &&*/ (S.design1612
  1123. ? " checked"
  1124. : "") +
  1125. (1 ? " disabled" : "") +
  1126. "/>" +
  1127. '<input type="checkbox" class="des18" id="whiteMintOval"' +
  1128. (S.whiteMintOval ||
  1129. S.whiteMintOval === undefined
  1130. ? " checked"
  1131. : "") +
  1132. "/>" +
  1133. '<label for="whiteMintOval" id="whiteMintOvalL">' +
  1134. $L["Gray design of buttons"] +
  1135. "</label><br/>" +
  1136. '<input type="checkbox" class="butTyp" id="butTypes"' +
  1137. (S.hiddenEdgeLeft ? "" : " checked") +
  1138. "/>" +
  1139. '<label for="butTypes" id="butTypesL">' +
  1140. $L["Show Filetype Button"] +
  1141. "</label><br/>" +
  1142. '<i><a href="#" class="defa" style="float: right">Default settings</a></i>' +
  1143. $L.Sites +
  1144. ': <br/><textarea class="sites" style="width:97%" rows=8>' +
  1145. strSites +
  1146. "</textarea><br/>" +
  1147. '<a class="reload" href=# onclick="location.reload();return!1">' +
  1148. $L["reload page for effect"] +
  1149. "</a>" +
  1150. "</div>"),
  1151. },
  1152. cs: Object.assign(
  1153. {
  1154. position:
  1155. (sI != $LSettings ||
  1156. design1612 ||
  1157. layout1811) &&
  1158. !fTMore
  1159. ? "static"
  1160. : "absolute",
  1161. display: "block",
  1162. width:
  1163. sI != $LSettings
  1164. ? "auto"
  1165. : /en|es/.test(lang) || !lang
  1166. ? "3em"
  1167. : "4em",
  1168. height: sI != $LSettings ? "18px" : "16px",
  1169. margin: "2px 0 -1px -13px",
  1170. padding: "0 2px 0 1px",
  1171. minWidth: "42px",
  1172. top: 19 * j - 175 - 133 * fTMoreX2 + "px",
  1173. textAlign: "left",
  1174. fontWeight: "normal",
  1175. opacity: 1,
  1176. whiteSpace: "nowrap",
  1177. },
  1178. fTMore ? { top: "18px", left: "47px" } : {}
  1179. ),
  1180. on: {
  1181. click: (function (fTyp, pdf, fTMore) {
  1182. return function (ev) {
  1183. var t = ev.target;
  1184. var less = $q("#hoursLess"),
  1185. des16 = $q("#design1612"), //&& !layout1811
  1186. des18 = $q("#whiteMintOval"),
  1187. butTyp = $q("#butTypes"),
  1188. itrv =
  1189. t.getAttribute("date") ||
  1190. t.parentNode.getAttribute("date") ||
  1191. "",
  1192. num = (
  1193. t.getAttribute("site") ||
  1194. t.parentNode.getAttribute("site") ||
  1195. ""
  1196. ).replace(
  1197. /site/.test(itrv) ? /^/ : /\D/g,
  1198. ""
  1199. );
  1200. //console.log('==clic3:t,itrv,num,fTyp,pdf:',t, itrv, num,'|',fTyp,pdf);
  1201. if (
  1202. t.classList.contains("sett") ||
  1203. t.parentNode.classList.contains("sett")
  1204. ) {
  1205. ev.stopPropagation();
  1206. return;
  1207. }
  1208. if (less && /hoursLess/.test(t.id)) {
  1209. less.outerHTML =
  1210. '<input type="checkbox" class="less" id="hoursLess"' +
  1211. (less.getAttribute("checked") != null
  1212. ? ""
  1213. : ' checked="checked"') +
  1214. "/>";
  1215. saveLocStor();
  1216. }
  1217. if (des16 && /design1612/.test(t.id)) {
  1218. des16.outerHTML =
  1219. '<input type="checkbox" class="des16" id="design1612"' +
  1220. (des16.getAttribute("checked") != null
  1221. ? ""
  1222. : ' checked="checked"') +
  1223. "/>";
  1224. saveLocStor();
  1225. }
  1226. if (des18 && /whiteMintOval/.test(t.id)) {
  1227. des18.outerHTML =
  1228. '<input type="checkbox" class="des18" id="design1612"' +
  1229. (des18.getAttribute("checked") != null
  1230. ? ""
  1231. : ' checked="checked"') +
  1232. "/>";
  1233. saveLocStor();
  1234. }
  1235. if (butTyp && /butTypes/.test(t.id)) {
  1236. butTyp.outerHTML =
  1237. '<input type="checkbox" class="butTyp" id="butTypes"' +
  1238. (butTyp.getAttribute("checked") != null
  1239. ? ""
  1240. : ' checked="checked"') +
  1241. "/>";
  1242. saveLocStor();
  1243. }
  1244. if (pdf || /site/.test(itrv)) {
  1245. //console.log('==pdf|site');
  1246. inputSearch.value = inputSearch.value.replace(
  1247. new RegExp(
  1248. "(?:(\\s+OR\\s+)?\\s*" +
  1249. (pdf ? "filetype" : "site") +
  1250. "(?::|%3A)\\s*\\S*)+|$",
  1251. "g"
  1252. ),
  1253. (s1) =>
  1254. fTMore || s1
  1255. ? ""
  1256. : " " +
  1257. (imSrch
  1258. ? itrv.toLowerCase() + num
  1259. : itrv + (pdf ? "" : fTyp))
  1260. );
  1261. }
  1262. var l2 = startPg
  1263. ? lh.replace(
  1264. /^([^/]*)\/\/([^/]+)\/?([^?#]*)([?#]?.*)/,
  1265. "$1//$2/search$4"
  1266. )
  1267. : lh, // insert '/search?' instead any
  1268. newSrch = /[?&]q=/.test(l2)
  1269. ? l2.replace(
  1270. /(&|\?)q=([^&]*)(&|$)/g,
  1271. "$1q=" +
  1272. encodeURIComponent(
  1273. inputSearch.value
  1274. ) +
  1275. "$3"
  1276. ) //add value to '[?&]q=[^&]*'
  1277. : l2 +
  1278. (/\?/.test(l2) ? "&" : "?") +
  1279. "q=" +
  1280. encodeURIComponent(inputSearch.value); //set new value as &q=.+
  1281. //console.log('==inputSearch.value,newSrch,fTyp,pdf,num', inputSearch.value, newSrch, fTyp, pdf, num);
  1282. if (
  1283. (pdf && !fTMore) ||
  1284. (num !== "" && num != +num)
  1285. ) {
  1286. ev.stopPropagation();
  1287. }
  1288. if (
  1289. buttSearcStart &&
  1290. ((pdf && !fTMore) ||
  1291. (num !== "" && num != +num))
  1292. ) {
  1293. buttSearcStart.click();
  1294. return;
  1295. }
  1296. if ((layout1811 && num !== "") || pdf) {
  1297. pdf && ev.stopPropagation();
  1298. if (!fTMore)
  1299. location.href = /qdr(:|%3A)([dwmyh])\d*/.test(
  1300. l2
  1301. )
  1302. ? newSrch.replace(
  1303. /([?&]tbs=)?qdr(:|%3A)[dwmyh]\d*/,
  1304. function (x) {
  1305. return pdf
  1306. ? ""
  1307. : (
  1308. itrv + (imSrch ? "" : num)
  1309. ).replace(
  1310. /&/,
  1311. /\?/.test(x) ? "?" : "&"
  1312. );
  1313. }
  1314. ) //patch date in URL
  1315. : newSrch +
  1316. (/\?/.test(newSrch) ? "&" : "?") +
  1317. (pdf
  1318. ? ""
  1319. : itrv + (imSrch ? "" : num));
  1320. //add date in URL
  1321. else {
  1322. if (t.classList.contains("txt")) {
  1323. if (
  1324. t.parentNode.classList.contains(
  1325. "more"
  1326. )
  1327. )
  1328. t.parentNode.className =
  1329. "xButt lsb moreShow";
  1330. else
  1331. t.parentNode.className =
  1332. "xButt lsb more";
  1333. } //'className' because bug of Chrome in upper line with .toggle
  1334. else {
  1335. if (t.classList.contains("more"))
  1336. t.className = "xButt lsb moreShow";
  1337. else t.className = "xButt lsb more";
  1338. }
  1339. }
  1340. } //bug of Fx with .toggle,.toggle - list is changed slow (0.4 s)
  1341. $pd(ev);
  1342. };
  1343. })(fTyp, i == "PDF", fTMore),
  1344. }, //, mouseover: function(ev){ev.stopPropagation()}, mouseout: function(ev){ev.stopPropagation()}
  1345. apT: siteList,
  1346. });
  1347. }
  1348. siteList.style.height = "auto";
  1349. siteList.style.textAlign = "center";
  1350. siteList.style.marginRight = "-40px";
  1351. }
  1352. }
  1353. },
  1354. });
  1355. }),
  1356. el: d.body,
  1357. });
  1358. } catch (er) {
  1359. console.log("==cB");
  1360. cB();
  1361. }
  1362. var saveLocStor = function (ev, val, do2) {
  1363. var aaa,
  1364. aab,
  1365. aac,
  1366. aad,
  1367. aae,
  1368. aaf,
  1369. t = (ev && ev.target.form) || document.documentElement || document.body;
  1370. xLocStor({
  1371. do: do2 || "set",
  1372. key: "sett",
  1373. val: {
  1374. lang: (aaa = d.querySelectorAll(".lang", t))[aaa.length - 1].value,
  1375. sites: (
  1376. (aab = d.querySelectorAll(".sites", t))[aab.length - 1].value || ""
  1377. )
  1378. .replace(/^[ \t]*|[ \n\t]*$/g, "")
  1379. .split("\n"),
  1380. lastHoursLess: (aac = d.querySelectorAll(".less", t))[aac.length - 1]
  1381. .checked,
  1382. design1612: (aad = d.querySelectorAll(".des16", t))[aad.length - 1]
  1383. .checked,
  1384. whiteMintOval: (aae = d.querySelectorAll(".des18", t))[aae.length - 1]
  1385. .checked,
  1386. hiddenEdgeLeft: !(aaf = d.querySelectorAll(".butTyp", t))[
  1387. aaf.length - 1
  1388. ].checked,
  1389. dwmyh: S.dwmyh || setts.dwmyh,
  1390. },
  1391. cB: function (prev) {
  1392. console.info("Settings are saved. prev=", prev);
  1393. },
  1394. });
  1395. $q(".siteList .settIn").classList.add("changed");
  1396. };
  1397. })({
  1398. //write "lang:''," to remove hints; 'en' for English hints (fr - Français, es - espagnol), 'ru' for Russian
  1399. lang:
  1400. "" ||
  1401. (navigator.languages && navigator.languages[1]) ||
  1402. navigator.language.substr(0, 2), //='' if hide hints, or 2 letters from $l{}
  1403. sites: [
  1404. //=array or one site in string
  1405. "",
  1406. "slashdot.org",
  1407. "reddit.com",
  1408. "techcrunch.com",
  1409. "habr.com",
  1410. "geektimes.com",
  1411. "smashingmagazine.com",
  1412. "engadget.com",
  1413. ], //write your favorite sites
  1414. lastHoursLess: 1, //=boolean - not show odd some values of hours after 8 h
  1415. design1612: 0, //=boolean - gray design is disabled for layout1811 ===== TODO enable
  1416. whiteMintOval: 1, //=boolean - white-mint-oval design with sticked search field
  1417. hiddenEdgeLeft: 0, //how many extra buttons to hide from left
  1418. dwmyh: [1, 1, 1, 1, 1], //=array of numbers - current vals of days, weeks, months, years, hours
  1419. fileType: {}, // turn on or off {doc:1, txt:1}
  1420. meta: {}, // on/off {Ask:1, }
  1421. //TODO meta-data for search of same results {Ya:{title:'',txt:'',url:''},...}
  1422. imgFile: "", // one of: switch to img search or in img search
  1423. imgType: {}, //{itp:'face'}
  1424. imgColor: {}, //{isc:'blue'}
  1425. imgSize: {}, //{isz:'i'}
  1426. imgSizeLt: {}, //{islt:'vga'}
  1427. });