Google Search Extra Buttons

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

当前为 2016-12-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Google Search Extra Buttons
  3. // @name:ru GoogleSearchExtraButtons
  4. // @description Add buttons (last 1/2/3 days, weeks, PDF search etc.) for Google search page
  5. // @description:ru Кнопки вариантов поиска для страницы поиска Google (1-2-3 дня, недели, PDF, ...)
  6. // @version 21.2016.12.7
  7. // @namespace spmbt.github.com
  8. // @include http://www.google.*/search*
  9. // @include https://www.google.*/search*
  10. // @include https://www.google.*/*
  11. // @include https://encrypted.google.*/search*
  12. // @include https://encrypted.google.*/*
  13. // @include https://spmbt.github.io/googleSearchExtraButtons/saveYourLocalStorage.html
  14. // ==/UserScript==
  15. if(location.host=='spmbt.github.io'){
  16. window.addEventListener('message', function(ev){
  17. if(/^https?:\/\/www\.google\./.test(ev.origin)){
  18. var d = typeof ev.data =='string' && ev.data[0] =='{' ? JSON.parse(ev.data) : ev.data;
  19. if(!d.do) return;
  20. var tok = d.tok, key = d.key;
  21. switch(d.do){
  22. case 'set':
  23. var prev = localStorage[key];
  24. if(d.val !==undefined)
  25. localStorage[key] = JSON.stringify(d.val);
  26. else
  27. localStorage.removeItem(key);
  28. break;
  29. case 'get':
  30. prev = localStorage[key];
  31. prev = prev === undefined || typeof prev =='string'&& prev[0] !='{'? prev : JSON.parse(prev);
  32. break;
  33. case 'remove':
  34. prev = localStorage[key];
  35. if(prev !==undefined)
  36. localStorage.removeItem(key);
  37. }
  38. //console.log('[io]', tok, 'prev=', prev);
  39. //ev.source.postMessage(JSON.stringify(prev !==undefined ? {tok: tok, prev: prev} : {tok: tok, undef:1}), ev.origin);
  40. }},!1);
  41. }else
  42.  
  43. (function(setts){ //lang, sites, lastHoursLess
  44.  
  45. var $x = function(el, h){if(h) for(var i in h) el[i] = h[i]; return el;} //===extend===
  46. ,$pd = function(ev){ev.preventDefault();}
  47. ,$q = function(q, el){return (el||document).querySelector(q)}
  48. ,lh = location.href
  49. ,d = document
  50. ,$e = function(g){ //===create or use existing element=== //g={el|clone,cl,ht,cs,at,atRemove,on,apT}
  51. g.el = g.el || g.clone ||'DIV';
  52. var o = g.o = g.clone && g.clone.cloneNode && g.clone.cloneNode(!0)
  53. || (typeof g.el =='string' ? d.createElement(g.el) : g.el);
  54. if(o){ //execute if exist
  55. if(g.cl)
  56. o.className = g.cl;
  57. if(g.clRemove)
  58. o.classList.remove(g.clRemove);
  59. if(g.clAdd)
  60. o.classList.add(g.clAdd);
  61. if(g.cs)
  62. $x(o.style, g.cs);
  63. if(g.ht || g.at){
  64. var at = g.at ||{}; if(g.ht) at.innerHTML = g.ht;}
  65. if(at)
  66. for(var i in at){
  67. if(i=='innerHTML') o[i] = at[i];
  68. else o.setAttribute(i, at[i]);}
  69. if(g.atRemove)
  70. for(var i in g.atRemove)
  71. o.removeAttribute(g.atRemove[i]);
  72. if(g.on)
  73. for(var i in g.on) if(g.on[i])
  74. o.addEventListener(i, g.on[i],!1);
  75. g.ap && o.appendChild(g.ap);
  76. g.apT && g.apT.appendChild(o);
  77. }
  78. return o;
  79. },
  80. addRules = function(css){
  81. var heads = d.getElementsByTagName('head')
  82. ,node = d.createElement('style');
  83. heads.length && heads[0].appendChild(node);
  84. node.appendChild(d.createTextNode(css));
  85. };
  86. /**
  87. * check occurrence of third-party event with growing interval
  88. * @constructor
  89. * @param{Number} h.t start period of check
  90. * @param{Number} h.i number of checks
  91. * @param{Number} h.m multiplier of period increment
  92. * @param{Function} h.check event condition
  93. * @param{Function} h.occur event handler
  94. */
  95. var Tout = function(h){
  96. var th = this;
  97. (function(){
  98. if((h.dat = h.check() )) //wait of positive result, then occurs
  99. h.occur();
  100. else if(h.i-- >0) //next slower step
  101. th.ww = setTimeout(arguments.callee, (h.t *= h.m) );
  102. })();
  103. }
  104. //for xLocStor:
  105. ,xLocStorOrigin = d.location.protocol +'//spmbt.github.io'
  106. ,qr, qrs ={} //set of queries "key-calls" (ок, toutLitt, toutLong, noService, noStorage)
  107. ,qrI = 0 //queries counter
  108. ,qrN = 12 //max number of waiting queries
  109. ,errIMax = 120, errNMax = errIMax //max number of errors
  110. ,ns ='googXButtons_' //namespace for keys
  111. ,listenMsg
  112. /**
  113. * external localStorage for using another domain if current domain storage is erased anywhere
  114. * @param{String} h.do - action: set|get|remove
  115. * @param{String} h.key
  116. * @param{Object|undefined} h.val (any type)
  117. * @param{Number|undefined} h.toutLitt
  118. * @param{Number|undefined} h.tout
  119. * @param{Function} h.cB - callback with 2 arguments
  120. * @param{Function|undefined} h.err - callback for err with one argument
  121. */
  122. ,xLocStor = function(h){
  123. var h0 = h;
  124. h.toutLitt = h.toutLitt || 400;
  125. h.tout = h.tout || 4000;
  126. var ifr = d.getElementById('xLocStor')
  127. ,query = function(){
  128. if((qrI += 1) > qrN){
  129. xCatch('longQrs', null, h);
  130. return;}
  131. ifr.contentWindow.postMessage(JSON.stringify($x({
  132. do: h.do
  133. ,tok: token
  134. ,key: ns + h.key
  135. }, h.val !==undefined ? {val: h.val}:{}) )
  136. , xLocStorOrigin);
  137. qrs[token] = $x({ //for wait of response
  138. wToutLitt: (function(h, qrI, errIMax){return setTimeout(function(){
  139. qrI -= 1;
  140. if((errIMax -= 1) >=0)
  141. ;//console.warn('toutLitt', h);
  142. chkErrMax();
  143. }, h.toutLitt);})(h, qrI, errIMax)
  144. ,wTout: (function(h, qrI){return setTimeout(function(){
  145. qrI -= 1;
  146. //xCatch('tout', null, h);
  147. //xLocStor(h0);
  148. }, h.tout);})(h, qrI)
  149. }, h);
  150. }
  151. ,token = +new Date() + (Math.random()+'').substr(1,8)
  152. ,el = h.el;
  153. delete h.el;
  154. if(ifr) query();
  155. else ifr = $e({
  156. el: 'iframe',
  157. at:{id: 'xLocStor'
  158. ,src: xLocStorOrigin +'/googleSearchExtraButtons/saveYourLocalStorage.html'},
  159. cs: {display: 'none'},
  160. on: {load: query},
  161. apT: el || d.body
  162. });
  163. if(!listenMsg) addEventListener('message', function(ev){
  164. if(ev.origin == xLocStorOrigin){ // {"tok":"<value>"[,"err":"<txt>"],"h":...}
  165. //console.log('from_io', JSON.parse(ev.data))
  166. var resp = ev.data && ev.data[0] =='{' && JSON.parse(ev.data);
  167. if(!resp) xCatch('bad_format', resp, h);
  168. if(( qr = qrs[resp.tok] )){
  169. qrI -= 1;
  170. qr.cB(resp.prev, resp.undef);
  171. var er = qr.err;
  172. delete qrs[resp.tok];} // else ignore unsufficient token
  173. if(resp.err && (!er || er(resp.err)) ) //individual or common error processing depends of er()
  174. xCatch(resp.err, resp, h);
  175. }},!1);
  176. listenMsg =1;
  177. },
  178. //for tests: localStorage.googXButtons_dwmyh = JSON.stringify({h:[1,2,1,1,1]})
  179. //$('#xLocStor').contentWindow.postMessage('{"do":"get","key":"googXButtons_dwmyh"}','https://spmbt.github.io')
  180. xCatch = function(er, resp, h){
  181. if((errIMax -= 1) >=0)
  182. console.error('tok:', resp && resp.tok ||'--','; err:', er,'; h:', h,'; respH:', resp && resp.h);
  183. chkErrMax();
  184. },
  185. chkErrMax = function(){if(!errIMax) console.error('Too many err messages:', errNMax)}
  186. ,$l ={ru:{
  187. 'search in PDF files':'поиск по документам PDF'
  188. ,'search in':'искать по'
  189. ,'from / to':'за период'
  190. ,'last':['за последний','за последние','за последнюю']
  191. ,'day':'сутки'
  192. ,'days':['дня','дней']
  193. ,'week':'неделю'
  194. ,'weeks':['недели','недель']
  195. ,'month':'месяц'
  196. ,'months':['месяца','месяцев']
  197. ,'year':'год'
  198. ,'years':['года','лет']
  199. ,'hour':'час'
  200. ,'hours':['часа','часов']
  201. ,'Settings':'Настройки'
  202. ,'of userscript':'юзерскрипта'
  203. ,'reload page for effect':'перезагрузить страницу'
  204. ,'Interface language':'Язык интерфейса'
  205. ,'Less positions at the end of selects':'Меньше выбора в конце селектов'
  206. ,'Sites':'Сайты'
  207. },fr:{
  208. 'search in PDF files':'la recherche dans les fichiers PDF'
  209. ,'search in':'rechercher dans'
  210. ,'from / to':'pour la période'
  211. ,'last':['le dernier','dans les derniers','dans les derniers']
  212. ,'day':'jour'
  213. ,'days':['jours','jours']
  214. ,'week':'semaine'
  215. ,'weeks':['semaines','semaines']
  216. ,'month':'mois'
  217. ,'months':['mois','mois']
  218. ,'year':'an'
  219. ,'years':['ans','ans']
  220. ,'hour':'heure'
  221. ,'hours':['heures','heures']
  222. ,'Settings':'Paramètres'
  223. ,'of userscript':'de Userscript'
  224. ,'reload page for effect':'recharger la page pour effet'
  225. ,'Interface language':'Langue de l\'interface'
  226. ,'Less positions at the end of selects':'Moins de choix les longues listes'
  227. ,'Sites':'Les sites'
  228. },de:{
  229. 'search in PDF files':'Suche in PDF-Dateien'
  230. ,'search in':'Suche in'
  231. ,'from / to':'im Zeitraum'
  232. ,'last':['letzte','letzte','letzte']
  233. ,'day':'Tag'
  234. ,'days':['Tage','Tage']
  235. ,'week':'Woche'
  236. ,'weeks':['Wochen','Wochen']
  237. ,'month':'Monat'
  238. ,'months':['Monate','Monate']
  239. ,'year':'Jahr'
  240. ,'years':['Jahre','Jahre']
  241. ,'hour':'Stunde'
  242. ,'hours':['Stunden','Stunden']
  243. ,'Settings':'Einstellungen'
  244. ,'of userscript':'von Userscript'
  245. ,'reload page for effect':'Seite neu laden'
  246. ,'Interface language':'Sprache'
  247. ,'Less positions at the end of selects':'Weniger Auswahl in langen Listen'
  248. ,'Sites':'Websites'
  249. },es:{
  250. 'search in PDF files':'búsqueda en archivos PDF'
  251. ,'search in':'busca en'
  252. ,'from / to':'para el período'
  253. ,'last':['el último','en los últimos','en los últimos']
  254. ,'day':'día'
  255. ,'days':['días','días']
  256. ,'week':'Semana'
  257. ,'weeks':['semanas','semanas']
  258. ,'month':'mes'
  259. ,'months':['meses','meses']
  260. ,'year':'año'
  261. ,'years':['años','años']
  262. ,'hour':'hora'
  263. ,'hours':['horas','horas']
  264. ,'Settings':'Ajustes'
  265. ,'of userscript':'de userscript'
  266. ,'reload page for effect':'página para efecto de recargar'
  267. ,'Interface language':'Idioma de interfaz'
  268. ,'Less positions at the end of selects':'Menos elección en listas largas'
  269. ,'Sites':'Sitios'
  270. }}; //if !lang, then no hints
  271. addRules('.hp .sfsbc,.sfsbc{display: inline-block}.siteList:hover button{display: block}'
  272. +'.gb_Ib >.gb_e{height:47px}.gb_Fb{z-index:1087}.tsf-p{z-index:203}'
  273. +'.lsbb .xButt,.sbibod .xButt,.lsbb >.siteList,.sbibod >.siteList{z-index: 2002; width:34px; height:17px; padding:0 2px; line-height:14px;'
  274. +'font-size:14px; border:1px solid transparent; background-color:#4889f1; color:#fff; opacity: 0.64}'
  275. +'.lsbb >.siteList,.sbibod >.siteList{width:32px; height:auto; padding:1px 0 2px; text-align:center}'
  276. +'.lsbb >.siteList .lsb,.sbibod >.siteList .lsb{font-weight: normal; color:#d4d4d4}.lsbb .lsb:hover,.sbibod .lsb:hover{opacity: 1; color:#fff}'
  277. +'.siteList .sett .txt{padding: 0 2px}'
  278. +'.siteList .settIn{display: none; width: 250px; padding: 2px 4px; text-align:left; border:1px solid #48f;'
  279. +'background-color:#eef; color:#336}'
  280. +'.siteList .settIn hr{margin:2px 0}'
  281. +'.sbibtd .sfsbc .nojsb, .siteList .sett:hover .settIn, .siteList .settIn.changed,'
  282. +'.siteList .settIn.changed .reload{display: block}.siteList .settIn .reload, .siteList.hiddn{display: none}'
  283. +'div.gb_g[aria-label="promo"]{display: none}'
  284. +'.srp #sfdiv{overflow: inherit}'); //hide promo
  285. xLocStor({do:'get', key:'sett', val:setts, cB: function(prev,undef){
  286. S = prev || setts;
  287. S.dwmyh = S.dwmyh || setts.dwmyh; //temp. transitional expr.
  288. console.timeStamp = function(){};
  289.  
  290. new Tout({t:120, i:8, m: 1.6
  291. ,check: function(){
  292. return d && d.getElementsByName('q') && d.getElementsByName('q')[0];
  293. },
  294. occur: function(){
  295. var lang = S.lang != null && S.lang || setts.lang
  296. ,sites = S.sites && (S.sites.length && S.sites[0] || S.sites.length >1) && S.sites
  297. || typeof sites =='string'&& [sites] || !S.sites && setts.sites || null;
  298. var strSites = sites && sites.join('\n').replace(/^\n/,'\n\n') ||''
  299. ,$L = $l[lang] || $l.ru; //default template of lang
  300. if(!lang || !$l[lang] || lang =='en') for(var l in $L){ //replace 'en' lang for default or substitution
  301. if($L[l] instanceof Array) for(var l2 in $L[l])
  302. $L[l][l2] = l;
  303. else
  304. $L[l] = l;
  305. }
  306. var $LSettings = $L['Settings'];
  307. if(sites && sites.length)
  308. sites.push($LSettings)
  309. var mainPg = /\/search\?/.test(lh)
  310. ,inputSearch = this.dat
  311. ,design1612 = $q('#_fZl') || $q('.sbico-c')
  312. ,buttSearch = d.getElementsByName("btnG") && d.getElementsByName('btnG')[0] || design1612
  313. ,buttS ={
  314. PDF:{url:'filetype:pdf', txt:$L['search in PDF files']}
  315. ,site:{url:'site:'+ S.sites[0], txt:$L['search in']+' '+ S.sites[0], one:'day'} //you may comment this line
  316. ,'.. : ..':{url:'', txt:$L['from / to']}
  317. ,'1D':{url:'&tbs=qdr:d', txt:$L['last'][1] +' '+ $L['day'], one:'day', up:13,lett:'D'}
  318. ,'1W':{url:'&tbs=qdr:w', txt:$L['last'][2] +' '+ $L['week'], one:'week', up:14,lett:'W'}
  319. ,'1M':{url:'&tbs=qdr:m', txt:$L['last'][0] +' '+ $L['month'], one:'month', up:20,lett:'M'}
  320. ,'1Y':{url:'&tbs=qdr:y', txt:$L['last'][0] +' '+ $L['year'], one:'year', up:10,lett:'Y'}
  321. ,'1H':{url:'&tbs=qdr:h', txt:$L['last'][0] +' '+ $L['hour'], one:'hour', up:23,lett:'H'}
  322. ,DOC:{url:'filetype:doc', txt:$L['search in PDF files'].replace(/PDF/,'DOC')}
  323. }, ii = 0, iD = -1;
  324. !sites && delete buttS.site;
  325. buttSearch.parentNode.style.position ='relative';
  326. if(buttSearch && top == self) for(var i in buttS) if(i !='site'|| S.sites){ //buttons under search input line
  327. if(i.length ==2) iD++; else iD=-1;
  328. var bI = buttS[i]
  329. ,Gesch = ({m:'letzter',f:'letzte',n:'letztes'})['m,f,m,n,f'.split(',')[iD]]
  330. ,hint = function(j){return (j+1) +' '+ (j % 10 || j==10 ? $L[bI.one +'s'][j % 10 <4 && (j/10|0)!=1 ?0:1] : $L[bI.one]) }
  331. ,csLeft = function(ii,a){a = -127 + 37 * (ii-1 - (ii >2 && !mainPg)); return design1612 ?{right: -a+33+'px'}:{left: a+'px'}}
  332. ,butt2 = $e({clone: i =='site'|| i.length ==2
  333. ? $e({cl: 'siteList', cs: {cursor:'default'}, at: {site: S.sites[0], date: bI.url} })
  334. : i !='.. : ..'|| mainPg ? $e({el:'button', cl: 'xButt' +(design1612 ?'':' lsb')}) : $e({cl: 'siteList hiddn'})
  335. ,at: {value: iD !=-1 && S.dwmyh[iD] !=1 ? S.dwmyh[iD] + bI.lett : i
  336. ,innerHTML: '<span class=txt onclick=this.parentNode.click();return!1 title="' +(lang || i=='site'|| i=='.. : ..'
  337. ? (iD==-1 || S.dwmyh[iD]==1 ? bI.txt : $L['last'][1] +' '+ hint(S.dwmyh[iD]-1)).replace(/letzte/,Gesch) :'')+'">'
  338. +(iD !=-1 && S.dwmyh[iD] !=1 ? S.dwmyh[iD] + bI.lett : i) +'</span>'}
  339. ,cs: $x({position:'absolute', top:'33px'}, csLeft(++ii))
  340. ,on: {click: (function(bI, i, iD){
  341. return /PDF|DOC|site/.test(i)
  342. ? function(ev){
  343. var doc, t = ev.target;
  344. if(t.className =='defa')
  345. saveLocStor('','','remove'); $pd(ev);
  346. if(((t.getAttribute('site') ==null && t.parentNode.getAttribute('site') ==null)
  347. || t.getAttribute('site')==$LSettings || t.parentNode.getAttribute('site')==$LSettings)
  348. && !/PDF|DOC/.test(t.getAttribute('value'))) return;
  349. //console.log('clic:',i,bI,ev, t.className, inputSearch.value, this.form)
  350. inputSearch.value = inputSearch.value.replace(/ site\:[\w.]*$/ig, '')
  351. .replace(/( |\+|&as_)filetype(:|%3A)[^\&]*/g,'') +' '+ (/PDF|DOC/.test(i) ? bI.url
  352. : 'site:'+ (t.getAttribute('site')|| t.parentNode.getAttribute('site')||''));
  353. if(/xButt|txt/.test(t.className) && !(i=='site' && !(/list/.test(t.parentNode.className) || /list/.test(t.parentNode.parentNode.className)))) buttSearch.click();
  354. }: !bI.url ? function(ev){ //from-to date
  355. var el = $q('#cdrlnk'), o;
  356. el && el.dispatchEvent(((o = d.createEvent('Events')).initEvent('click', !0, !1), o));
  357. $pd(ev);
  358. }: function(ev){ //last interval
  359. location.href = '/search?q='+ encodeURIComponent(inputSearch.value)
  360. +((ev.target.getAttribute('date')||ev.target.parentNode.getAttribute('date'))
  361. + (ev.target.getAttribute('value')||ev.target.parentNode.getAttribute('value')).replace(/\D/g,'') || bI.url)
  362. +(/[&?]tbm=/.test(lh) ? '&'+/tbm=[^&]*/.exec(lh)[0]:''); //saving type of page
  363. S.dwmyh[iD] = +(ev.target.getAttribute('value')||ev.target.parentNode.getAttribute('value')).replace(/\D/g,'');
  364. $pd(ev);
  365. ev.stopPropagation();
  366. saveLocStor();
  367. }
  368. })(bI, i, iD),
  369. mouseover: i =='site' || i.length ==2 ? (function(bI,i){return function(ev){
  370. clearTimeout(bI.ww);
  371. $q('.list', ev.currentTarget).style.display ='block';
  372. }})(bI,i) :'',
  373. mouseout: i =='site' || i.length ==2 ? (function(bI,i){return function(ev){
  374. var t = ev.currentTarget;
  375. clearTimeout(bI.ww);
  376. bI.ww = setTimeout(function(){
  377. $q('.list',t).style.display ='none';
  378. }, 450);
  379. }})(bI,i) :'',
  380. change: saveLocStor
  381. }
  382. ,apT: buttSearch.parentNode
  383. });
  384. bI.el = butt2;
  385. if(i =='site' || i.length ==2){ //dropdown lists under some buttons
  386. var siteList = $e({cl:'list',cs:{display:'none'}, apT: butt2}), arr =[];
  387. for(var j =0; j <= bI.up -1 -(i=='1W'&& S.lastHoursLess ?4:0) -(i=='1M'&& S.lastHoursLess ?9:0); j++)
  388. if(i !='1H' || !S.lastHoursLess || j < 8 || j % 2 )
  389. arr.push(hint(j));
  390. //console.log(S.sites,i, S.dwmyh);
  391. var list = i == 'site' ? sites||[] : i =='1D'&& !sites ? arr.concat([$LSettings]) : arr;
  392. for(var j in list) if(j !=0 || iD!=-1 && S.dwmyh[iD] !=1)
  393. var sI = list[j]
  394. ,butt3 = $e({clone: sI==$LSettings
  395. ? $e({cl: 'sett' +(design1612 ?' xButt':' lsb')})
  396. : $e({el:'button', cl: 'xButt' +(design1612 ?'':' lsb')})
  397. ,at:{value: sI
  398. ,site: sI
  399. ,date: bI.url
  400. ,title: sI==$LSettings || !lang ?'':(i =='site' ? $L['search in'] +' '+ sI
  401. : j==0 ? bI.txt : $L['last'][1] +' '+ sI).replace(/letzte/,Gesch)
  402. ,innerHTML:'<span class=txt>'+ sI +'</span>'+ (sI != $LSettings &&!(!S.sites && i =='1H')
  403. ?'':'<div class="settIn">'
  404. +$L.Settings +' '+ $L['of userscript'] +'<br>"Google Search Extra Buttons"<hr>'
  405. +$L['Interface language'] +': <select class="lang" style="width:70px">'
  406. +(function(){var s='<option'+ (lang=='en'?' selected':'') +'>en</option>';
  407. for(var i in $l)
  408. s+='<option'+ (lang==i ?' selected':'') +'>'+ i +'</option>';
  409. return s +'<option value=""'+ (lang==''?' selected':'') +'>en w/o hints</option>'})()
  410. +'</select><br>'
  411. +'<input type="checkbox" class="less" id="hoursLess"'+ (S.lastHoursLess ?' checked':'') +'/>'
  412. +'<label for="hoursLess" id="hoursLessL">'+ $L['Less positions at the end of selects'] +'</label><br>'
  413. +'<i><a href="#" class="defa" style="float: right">Default settings</a></i>'
  414. +$L.Sites +': <br><textarea class="sites" style="width:97%" rows=8>'
  415. + strSites +'</textarea><br>'
  416. +'<a class="reload" href=# onclick="location.reload();return!1">'
  417. + $L['reload page for effect'] +'</a>'
  418. +'</div>')}
  419. ,cs: {position: sI != $LSettings || design1612 ?'static':'absolute',display:'block', width: sI != $LSettings ?'auto': /en|es/.test(lang)||!lang ?'4em':'6.2em', height: sI != $LSettings ?'18px':'16px'
  420. ,margin:'2px 0 -1px -13px', padding:0, textAlign:'left', fontWeight:'normal', opacity:1}
  421. ,on:{click: function(ev){
  422. //console.log('c3',ev.target.outerHTML);
  423. var chk = $q('#hoursLess');
  424. if(chk && /hoursLess/.test(ev.target.id)){
  425. chk.outerHTML = '<input type="checkbox" class="less" id="hoursLess"'
  426. +(chk.getAttribute('checked')!=null ?'':' checked="checked"')+'>';
  427. saveLocStor();
  428. }
  429. $pd(ev);}}
  430. ,apT: siteList
  431. });
  432. siteList.style.height ='auto'; siteList.style.textAlign ='center';
  433. }
  434. }
  435. }
  436. });
  437.  
  438. }, el: d.body});
  439. var saveLocStor = function(ev, val, do2){ var aaa,aab,aac, t = ev && ev.target.form || document.documentElement || document.body;
  440. xLocStor({do: do2 ||'set', key:'sett'
  441. , val:{lang: (aaa=d.querySelectorAll('.lang', t))[aaa.length-1].value
  442. ,sites: (aab=d.querySelectorAll('.sites', t))[aab.length-1].value.replace(/^[ \t]*|[ \n\t]*$/g,'')
  443. .split('\n')
  444. ,lastHoursLess: (aac=d.querySelectorAll('.less', t))[aac.length-1].checked
  445. ,dwmyh: S.dwmyh || setts.dwmyh
  446. }
  447. ,cB: function(prev){
  448. console.info('Settings are saved. prev=', prev);}
  449. });
  450. $q('.siteList .settIn').classList.add('changed');
  451. };
  452.  
  453. })({ //write "lang:''," to remove hints; 'en' for English hints (fr - Français, es - espagnol), 'ru' for Russian
  454. lang:''|| (navigator.languages && navigator.languages[1] || navigator.language.substr(0,2)) //='' if hide hints, or 2 letters from $l{}
  455. ,sites: [ //=array or one site in string
  456. '','slashdot.org','reddit.com','techcrunch.com','habrahabr.ru','geektimes.ru'
  457. ,'smashingmagazine.com','engadget.com'] //write your favorite sites
  458. ,lastHoursLess: 1 //=boolean - not show odd some values of hours after 8 h
  459. ,dwmyh: [1,1,1,1,1] //=array of numbers - current vals of days, weeks, months, years, hours
  460. });