Google Search Extra Buttons

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

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

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