InoReader Filter

Highlight or remove articles in InoReader. / InoReaderの記事を消去もしくは強調表示します。

目前为 2014-05-13 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name InoReader Filter
  3. // @description Highlight or remove articles in InoReader. / InoReaderの記事を消去もしくは強調表示します。
  4. // @id InoReaderFilter
  5. // @namespace https://userscripts.org/scripts/show/352673
  6. // @homepage https://userscripts.org/scripts/show/352673
  7. // @include http://inoreader.com/*
  8. // @include https://inoreader.com/*
  9. // @include http://www.inoreader.com/*
  10. // @include https://www.inoreader.com/*
  11. // @include http://beta.inoreader.com/*
  12. // @include https://beta.inoreader.com/*
  13. // @include http://us.inoreader.com/*
  14. // @include https://us.inoreader.com/*
  15. // @exclude *inoreader.com/stream/*
  16. // @exclude *inoreader.com/m/*
  17. // @exclude *inoreader.com/old/stream*
  18. // @exclude *inoreader.com/old/m/*
  19. // @grant GM_addStyle
  20. // @grant GM_log
  21. // @version 1.11
  22. // ==/UserScript==
  23.  
  24. (function() {
  25. 'use strict';
  26.  
  27. var aNgTextarea = [],
  28. aNg = [],
  29. aNgId = [],
  30. aHiTextarea = [],
  31. aHi = [],
  32. aHiId = [],
  33. aAd = [],
  34. aAdId = [],
  35. aAdTemp,
  36. bExclude = false,
  37. nArticles = 0,
  38. nExcludes = 0,
  39. st = {},
  40. reAd = /^\s*(?:ad|pr|広告)\s*[::]|^\s*[\[[【](?:ad|pr|広告)[\]]】]|[\[[【](?:ad|pr|広告)[\]]】]\s*$/im,
  41. $id = function(id) {
  42. return document.getElementById(id);
  43. },
  44. notType = function(t, a) {
  45. return (Object.prototype.toString.call(a).slice(8, 11) !== t) ? true : false;
  46. },
  47. target = $id('subscriptions_articles') || $id('reader_pane'),
  48. config = {
  49. childList: true,
  50. subtree: true
  51. },
  52. iInit, LOC;
  53.  
  54. var convertRules = function() {
  55. aNg = [];
  56. aHi = [];
  57. aNgTextarea = (st.ngdata) ? st.ngdata.split(/\r\n|\n|\r/) : [];
  58. aHiTextarea = (st.hidata) ? st.hidata.split(/\r\n|\n|\r/) : [];
  59. var wildcardToRegexp = function(s) {
  60. return s.replace(/~\*/g, '<InoReaderFilterAM>')
  61. .replace(/~\?/g, '<InoReaderFilterQM>')
  62. .replace(/[.+\^=!:${}()|\[\]\/\\]/g, '\\$&')
  63. .replace(/\*/g, '.*')
  64. .replace(/\?/g, '.')
  65. .replace(/<InoReaderFilterAM>/g, '\\*')
  66. .replace(/<InoReaderFilterQM>/g, '\\?');
  67. },
  68. a = [aNg, aNgTextarea, aHi, aHiTextarea];
  69. for (var n = 0, m = a.length; n < m; n = n + 2) {
  70. for (var i = 0, j = a[n + 1].length; i < j; i++) {
  71. var str = a[n + 1][i],
  72. sFeed = '',
  73. sTitle = '',
  74. sText = '';
  75. a[n][i] = {};
  76. a[n][i].feedPattern = '';
  77. a[n][i].feedFlag = '';
  78. a[n][i].titlePattern = '';
  79. a[n][i].titleFlag = '';
  80. a[n][i].textPattern = '';
  81. a[n][i].textFlag = '';
  82. a[n][i].task = '';
  83. if (str.indexOf(st.delimiter) !== -1) {
  84. var arr = str.split(st.delimiter);
  85. sFeed = arr[0];
  86. if (arr.length === 2) sText = arr[1];
  87. else if (arr.length > 2) {
  88. sTitle = arr[1];
  89. sText = str.slice(arr[0].length + arr[1].length + (st.delimiter.length * 2));
  90. if (!arr[1]) a[n][i].task = 'text';
  91. }
  92. } else sText = str;
  93. if (sFeed) {
  94. if (/^\/.+\/g?i?y?$/.test(sFeed)) {
  95. a[n][i].feedPattern = sFeed.slice(sFeed.indexOf('/') + 1, sFeed.lastIndexOf('/'));
  96. a[n][i].feedFlag = sFeed.slice(sFeed.lastIndexOf('/') + 1);
  97. } else a[n][i].feedPattern = wildcardToRegexp(sFeed);
  98. }
  99. if (sTitle) {
  100. if (/^\/.+\/g?i?y?$/.test(sTitle)) {
  101. a[n][i].titlePattern = sTitle.slice(sTitle.indexOf('/') + 1, sTitle.lastIndexOf('/'));
  102. a[n][i].titleFlag = sTitle.slice(sTitle.lastIndexOf('/') + 1);
  103. } else a[n][i].titlePattern = wildcardToRegexp(sTitle);
  104. }
  105. if (sText) {
  106. if (/^\/.+\/g?i?y?$/.test(sText)) {
  107. a[n][i].textPattern = sText.slice(sText.indexOf('/') + 1, sText.lastIndexOf('/'));
  108. a[n][i].textFlag = sText.slice(sText.lastIndexOf('/') + 1);
  109. } else a[n][i].textPattern = wildcardToRegexp(sText);
  110. }
  111. }
  112. }
  113. };
  114.  
  115. var checkArticle = function(a, ft, at, du, tdu) {
  116. var feed = a.feedPattern,
  117. title = a.titlePattern,
  118. text = a.textPattern,
  119. task = a.task;
  120. if ((!title && !text) || /^\s+$/.test(title + text)) return false;
  121. var bFeed = new RegExp(feed, a.feedFlag + 'm').test(ft),
  122. bTitle = new RegExp(title, a.titleFlag).test(at),
  123. bDU = new RegExp(text, a.textFlag + 'm').test(du),
  124. bTDU = new RegExp(text, a.textFlag + 'm').test(tdu);
  125. if (!feed) {
  126. if (!title && bDU && task === 'text') return 'DU: ' + text;
  127. if (!title && bTDU && !task) return 'TDU: ' + text;
  128. if (bTitle && !text) return 'T: ' + title;
  129. if (bTitle && bDU) return 'T: ' + title + ' DU: ' + text;
  130. }
  131. if (bFeed) {
  132. if (!title && bDU && task === 'text') return 'F: ' + feed + ' DU: ' + text;
  133. if (!title && bTDU && !task) return 'F: ' + feed + ' TDU: ' + text;
  134. if (bTitle && !text) return 'F: ' + feed + ' T: ' + title;
  135. if (bTitle && bDU) return 'F: ' + feed + ' T: ' + title + ' DU: ' + text;
  136. }
  137. return '';
  138. };
  139.  
  140. var currentArticle = function() {
  141. var eSa = $id('subscriptions_articles') || $id('reader_pane');
  142. if (eSa) return eSa.getElementsByClassName('article_current');
  143. return [];
  144. };
  145.  
  146. var currentExpandedArticle = function() {
  147. var eSa = $id('subscriptions_articles') || $id('reader_pane');
  148. if (eSa) return eSa.getElementsByClassName('article_current article_expanded');
  149. return [];
  150. };
  151.  
  152. var currentTreeName = function() {
  153. var tlf = document.getElementById('tree').getElementsByClassName('selected');
  154. if (tlf.length && tlf[0] && tlf[0].textContent) return tlf[0].textContent;
  155. return '';
  156. };
  157.  
  158. var articleData = function(e) {
  159. var o = {};
  160. o.sId = '';
  161. o.sFeed = '';
  162. o.sTitle = '';
  163. o.sDesc = '';
  164. o.sUrl = '';
  165. o.sDate = '';
  166. o.sId = (e && e.id) ? e.id.slice(e.id.lastIndexOf('_') + 1) : '';
  167. if (!o.sId) return o;
  168. var eArticleFeed = $id('article_feed_info_link_' + o.sId) || e.getElementsByClassName('article_feed_title')[0] || document.evaluate('//div[@class="article_tile_footer_feed_title"]/a', e.cloneNode(true), null, 9, null).singleNodeValue,
  169. eArticleTitle = $id('at_' + o.sId) || $id('article_title_link_' + o.sId) || e.getElementsByClassName('article_title_link')[0],
  170. eArticleDesc = e.getElementsByClassName('article_short_contents')[0] || e.getElementsByClassName('article_tile_content')[0],
  171. eArticleUrl = $id('aurl_' + o.sId),
  172. eArticleDate = $id('header_date_' + o.sId);
  173. o.sFeed = (eArticleFeed) ? eArticleFeed.textContent : currentTreeName();
  174. o.sTitle = (eArticleTitle) ? eArticleTitle.textContent : '';
  175. o.sDesc = (eArticleDesc) ? eArticleDesc.textContent : '';
  176. o.sUrl = (eArticleUrl && eArticleUrl.hasAttribute('href')) ? eArticleUrl.getAttribute('href') : '';
  177. o.sDate = (eArticleDate && eArticleDate.hasAttribute('title')) ? eArticleDate.getAttribute('title') : '';
  178. if (/^\s+$/.test(o.sFeed)) o.sFeed = '';
  179. if (/^\s+$/.test(o.sTitle)) o.sTitle = '';
  180. if (/^\s+$/.test(o.sDesc)) o.sDesc = '';
  181. if (/^\s+$/.test(o.sUrl)) o.sUrl = '';
  182. if (/^\s+$/.test(o.sDate)) o.sDate = '';
  183. if (o.sDesc) o.sDesc = o.sDesc.replace(/^\s+-\s+(.+)/, '$1').replace(/(.+)\s+$/, '$1');
  184. if (o.sDate) o.sDate = o.sDate.slice(o.sDate.lastIndexOf(': ') + 2);
  185. return o;
  186. };
  187.  
  188. var mutation = function() {
  189. var eSa = $id('subscriptions_articles') || $id('reader_pane');
  190. if (!eSa) return;
  191. var articles = eSa.getElementsByClassName('ar'),
  192. bFoundCurrentArticle = false,
  193. eExpandedCurrentArticle,
  194. treeTitle = currentTreeName(),
  195. eAc = currentExpandedArticle();
  196. if (!articles.length || (nArticles > articles.length + nExcludes + 3)) {
  197. aHiId = [];
  198. aNgId = [];
  199. aAdId = [];
  200. bExclude = false;
  201. nArticles = 0;
  202. nExcludes = 0;
  203. return;
  204. }
  205. nArticles = articles.length + nExcludes;
  206. if (eAc.length) eExpandedCurrentArticle = eAc[0];
  207. loop1: for (var n1 = 0, l1 = articles.length; n1 < l1; n1++) {
  208. if (n1 === 0 && !st.hi && !st.ng) break;
  209. var eArticle = articles[n1],
  210. oA = articleData(eArticle);
  211. if (!oA.sId) continue;
  212. if (eArticle === eExpandedCurrentArticle) bFoundCurrentArticle = true;
  213. if (st.hi) {
  214. for (var n2 = 0, l2 = aHiId.length; n2 < l2; n2++) {
  215. if (oA.sId === aHiId[n2]) continue loop1;
  216. }
  217. }
  218. if (st.ng) {
  219. for (var n3 = 0, l3 = aNgId.length; n3 < l3; n3++) {
  220. if (oA.sId === aNgId[n3]) {
  221. nExcludes++;
  222. continue loop1;
  223. }
  224. }
  225. }
  226. if (st.ad) {
  227. for (var n4 = 0, l4 = aAdId.length; n4 < l4; n4++) {
  228. if (oA.sId === aAdId[n4]) {
  229. nExcludes++;
  230. continue loop1;
  231. }
  232. }
  233. }
  234. if (treeTitle) oA.sFeed += '\n' + treeTitle;
  235. var sArticleDU = oA.sDesc + '\n' + oA.sUrl,
  236. sArticleTDU = oA.sTitle + '\n' + oA.sDesc + '\n' + oA.sUrl,
  237. sCa = '';
  238. if (st.hi) {
  239. for (var i1 = 0, j1 = aHi.length; i1 < j1; i1++) {
  240. sCa = checkArticle(aHi[i1], oA.sFeed, oA.sTitle, sArticleDU, sArticleTDU);
  241. if (sCa) {
  242. if (st.log) GM_log('highlight: ' + oA.sTitle + ' / matching rule ' + sCa);
  243. $id('article_' + oA.sId).classList.add('inoreader_filter_highlight');
  244. aHiId.push(oA.sId);
  245. continue loop1;
  246. }
  247. }
  248. }
  249. if (bExclude) break;
  250. if (st.ad) {
  251. var sT = oA.sTitle.replace(/^\s*(?:ad|pr|広告)\s?[::]\s*(.+)$/i, '$1')
  252. .replace(/^\s*[\[[【](?:ad|pr|広告)[\]]】]\s*(.+)$/i, '$1')
  253. .replace(/^(.+)\s*[\[[【](?:ad|pr|広告)[\]]】]\s*$/i, '$1');
  254. for (var i2 = 0, j2 = aAd.length, a; i2 < j2; i2++) {
  255. if (!aAd[i2] || notType('Str', aAd[i2]) || aAd[i2].indexOf('<>') === -1) continue;
  256. else if (aAd[i2].slice(0, aAd[i2].lastIndexOf('<>')).indexOf(sT) !== -1) {
  257. a = aAd[i2].slice(aAd[i2].lastIndexOf('<>') + 2).split('@');
  258. if ((!eAc.length || bFoundCurrentArticle) && a.length === 2 && Number(a[1]) && $id('article_' + oA.sId) !== eExpandedCurrentArticle) {
  259. if (st.log) GM_log('remove ad: ' + oA.sTitle);
  260. target.removeChild($id('article_' + oA.sId));
  261. aAdId.push(oA.sId);
  262. nExcludes++;
  263. continue loop1;
  264. }
  265. }
  266. }
  267. }
  268. if (st.ng) {
  269. if (st.ad && reAd.test(oA.sTitle + '\n' + oA.sDesc) && oA.sDate && (oA.sDate.length <= 5 || (oA.sDate.length > 5 && new Date(oA.sDate).getTime() + 86400000 * 60 > Date.now()))) continue;
  270. for (var i3 = 0, j3 = aNg.length; i3 < j3; i3++) {
  271. sCa = checkArticle(aNg[i3], oA.sFeed, oA.sTitle, sArticleDU, sArticleTDU);
  272. if (sCa) {
  273. if (st.log) GM_log('remove: ' + oA.sTitle + ' / matching rule ' + sCa);
  274. target.removeChild($id('article_' + oA.sId));
  275. aNgId.push(oA.sId);
  276. nExcludes++;
  277. continue loop1;
  278. }
  279. }
  280. }
  281. }
  282. if ($id('unread_cnt_top')) $id('unread_cnt_top').setAttribute('data-ngcount', ' (' + (aNgId.length + aAdId.length) + ')');
  283. if (nArticles >= 50 && nExcludes / nArticles >= 0.8) {
  284. if (!bExclude) window.alert(LOC.t30);
  285. bExclude = true;
  286. }
  287. };
  288. var observer = new MutationObserver(mutation);
  289.  
  290. var createAdtable = function(type, flag) {
  291. var html = '',
  292. at = (aAdTemp || flag) ? aAdTemp.concat() : aAd.concat();
  293. switch (Number(type)) {
  294. case 0:
  295. at.sort(function(a, b) {
  296. var tA = a.slice(0, a.lastIndexOf('<>')),
  297. tB = b.slice(0, b.lastIndexOf('<>'));
  298. if (tA > tB) return 1;
  299. if (tA < tB) return -1;
  300. return 0;
  301. });
  302. break;
  303. case 1:
  304. at.sort(function(a, b) {
  305. var tA = a.slice(0, a.lastIndexOf('<>')),
  306. tB = b.slice(0, b.lastIndexOf('<>'));
  307. if (tA < tB) return 1;
  308. if (tA > tB) return -1;
  309. return 0;
  310. });
  311. break;
  312. case 2:
  313. at.sort(function(a, b) {
  314. var nA = a.slice(a.lastIndexOf('<>') + 2, -2),
  315. nB = b.slice(b.lastIndexOf('<>') + 2, -2);
  316. return Number(nB) - Number(nA);
  317. });
  318. break;
  319. case 3:
  320. at.sort(function(a, b) {
  321. var nA = a.slice(a.lastIndexOf('<>') + 2, -2),
  322. nB = b.slice(b.lastIndexOf('<>') + 2, -2);
  323. return Number(nA) - Number(nB);
  324. });
  325. break;
  326. }
  327. for (var i = 0, j = at.length, a, t, d; i < j; i++) {
  328. if (!at[i] || notType('Str', at[i]) || at[i].indexOf('<>') === -1) continue;
  329. t = at[i].slice(0, at[i].lastIndexOf('<>'));
  330. a = at[i].slice(at[i].lastIndexOf('<>') + 2).split('@');
  331. d = (a.length === 2 && Number(a[0]) >= 0) ? a[0] : '';
  332. if (!d) continue;
  333. html += '<div class="irf_tr"><div class="irf_ad_td1"><label><input id="irf_ad_switch_' + d + '" type="checkbox"' + (Number(a[1]) ? ' checked' : '') + ' value="' + a[1] + '" /><span title="' + LOC.t22 + ' : ' + new Date(Number(a[0])).toLocaleString() + '">' + t + '</span></label></div><div class="irf_ad_td2"><input id="irf_ad_remove_' + d + '" type="button" value="' + LOC.t12 + '" /></div></div>';
  334. }
  335. $id('irf_ad_table').innerHTML = html;
  336. };
  337.  
  338. var setSettingsTab = function(s) {
  339. for (var t = ['ng', 'hi', 'ad', 'etc'], i = 0; i < 4; i++) {
  340. $id('irf_tab_' + t[i]).classList.remove('irf_tab_selected');
  341. $id('irf_form_' + t[i]).style.display = 'none';
  342. }
  343. $id('irf_tab_' + s).classList.add('irf_tab_selected');
  344. $id('irf_form_' + s).style.display = 'block';
  345. if (s === 'ng' || s === 'hi') {
  346. if ($id('irf_' + s + '_add_word').getBoundingClientRect().left > 0)
  347. $id('irf_' + s + '_add_word').focus();
  348. else if ($id('irf_' + s + '_ta').getBoundingClientRect().left > 0)
  349. $id('irf_' + s + '_ta').focus();
  350. }
  351. };
  352.  
  353. var settingsMode = function(s) {
  354. var e = $id('irf_settings').getElementsByClassName('irf_advance');
  355. for (var i = 0, j = e.length; i < j; i++) {
  356. if (s === 'simple') e[i].classList.add('inoreader_filter_hide');
  357. else if (s === 'advance') e[i].classList.remove('inoreader_filter_hide');
  358. }
  359. };
  360.  
  361. var viewSettings = function() {
  362. var se = $id('irf_settings');
  363. if (!se) return;
  364. if (se.style.display !== 'block') {
  365. setSettingsTab('ng');
  366. $id('irf_ng_add_bt').classList.add('inoreader_filter_hide');
  367. $id('irf_hi_add_bt').classList.add('inoreader_filter_hide');
  368. $id('irf_ng_fill_bt').classList.remove('inoreader_filter_hide');
  369. $id('irf_hi_fill_bt').classList.remove('inoreader_filter_hide');
  370. $id('irf_ng_cb').checked = st.ng;
  371. $id('irf_hi_cb').checked = st.hi;
  372. $id('irf_ad_cb').checked = st.ad;
  373. if (st.ng) $id('irf_ng_fs').removeAttribute('disabled');
  374. else $id('irf_ng_fs').setAttribute('disabled', '');
  375. if (st.hi) $id('irf_hi_fs').removeAttribute('disabled');
  376. else $id('irf_hi_fs').setAttribute('disabled', '');
  377. $id('irf_ng_add_word').value = '';
  378. $id('irf_hi_add_word').value = '';
  379. $id('irf_ng_add_feed').value = '';
  380. $id('irf_hi_add_feed').value = '';
  381. $id('irf_ng_add_title').value = '';
  382. $id('irf_hi_add_title').value = '';
  383. $id('irf_ng_ta').value = st.ngdata;
  384. $id('irf_hi_ta').value = st.hidata;
  385. $id('irf_ad_sort_type')[Number(st.adsort)].selected = true;
  386. if (st.mode === 'simple') $id('irf_etc_mode-s').checked = true;
  387. else if (st.mode === 'advance') $id('irf_etc_mode-a').checked = true;
  388. $id('irf_etc_key_settings').value = st.keywindow;
  389. $id('irf_etc_delimiter').value = st.delimiter;
  390. $id('irf_etc_log').checked = st.log;
  391. aAdTemp = null;
  392. createAdtable(st.adsort);
  393. settingsMode(st.mode);
  394. se.style.display = 'block';
  395. if ($id('irf_ng_add_word').getBoundingClientRect().left > 0) $id('irf_ng_add_word').focus();
  396. else if ($id('irf_ng_ta').getBoundingClientRect().left > 0) $id('irf_ng_ta').focus();
  397. } else {
  398. se.style.display = 'none';
  399. $id('irf_ok').removeAttribute('disabled');
  400. }
  401. };
  402.  
  403. var loadSettings = function() {
  404. st = {};
  405. try {
  406. st = JSON.parse(localStorage.getItem('InoReaderFilter_settings')) || {};
  407. } catch (er) {
  408. alert('InoReaderFilter Error: Load Settings');
  409. }
  410. if (notType('Num', st.format)) st.format = 1;
  411. if (notType('Boo', st.ng)) st.ng = true;
  412. if (notType('Boo', st.hi)) st.hi = true;
  413. if (notType('Boo', st.ad)) st.ad = true;
  414. if (notType('Str', st.ngdata)) st.ngdata = '';
  415. if (notType('Str', st.hidata)) st.hidata = '';
  416. if (notType('Num', st.adcount)) st.adcount = 0;
  417. if (notType('Num', st.adsort)) st.adsort = 0;
  418. if (notType('Str', st.mode)) st.mode = 'simple';
  419. if (notType('Str', st.keywindow)) st.keywindow = 'F';
  420. if (notType('Str', st.delimiter)) st.delimiter = '<>';
  421. if (notType('Boo', st.log)) st.log = false;
  422. convertRules();
  423. };
  424.  
  425. var saveSettings = function(flag) {
  426. try {
  427. localStorage.setItem('InoReaderFilter_settings', JSON.stringify(st));
  428. } catch (er) {
  429. alert('InoReaderFilter Error: Save Settings');
  430. }
  431. if (!flag) convertRules();
  432. };
  433.  
  434. var loadAddata = function() {
  435. try {
  436. aAd = JSON.parse(localStorage.getItem('InoReaderFilter_addata')) || [];
  437. } catch (er) {}
  438. };
  439.  
  440. var saveAddata = function(a) {
  441. if (aAdTemp) {
  442. aAd = aAdTemp.concat();
  443. aAdTemp = null;
  444. }
  445. try {
  446. localStorage.setItem('InoReaderFilter_addata', JSON.stringify(a));
  447. } catch (er) {
  448. alert('InoReaderFilter Error: Save AdData');
  449. }
  450. loadAddata();
  451. };
  452.  
  453. var init = function() {
  454. if (!target) return;
  455. loadSettings();
  456. loadAddata();
  457. var CSS =
  458. '#unread_cnt_top:after { content: attr(data-ngcount); }' +
  459. '.inoreader_filter_highlight span[id^="at_"], .inoreader_filter_highlight a[id^="article_title_link_"], .inoreader_filter_highlight .article_title_link { color: #B65F06; }' +
  460. '.inoreader_filter_hide { display: none; }' +
  461. '#irf_settings { display: none; color: black; padding: 0; position: absolute; top: 48px; left: 48px; z-index: 90300; background: rgba(255, 255, 255, 0.98); border: 1px solid #999999; border-radius: 4px; box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2); min-width: 20em; }' +
  462. '#irf_settings input[type="button"] { font-size: 90%; height: 2em; }' +
  463. '#irf_titlebar { background-color: #666666; border-radius: 4px 4px 0 0; padding: 2px 0 0 4px; height: 2em; -moz-user-select: none; -webkit-user-select: none; }' +
  464. '#irf_title a { font-weight: bold; color: white; text-decoration: none; }' +
  465. '#irf_title a:hover { color: #FF9; }' +
  466. '#irf_title_btn { position: absolute; top: 2px; right: 4px; }' +
  467. '#irf_desc { padding: 0 0.5em; margin: 0.5em 0 1em 0; }' +
  468. '#irf_tab { padding: 0 0.5em; margin-top: 1em; }' +
  469. '#irf_tab span { background-color: #E9E9E9; border: 1px solid #999999; padding: 3px 16px; border-radius: 4px 4px 0 0; cursor: pointer; }' +
  470. '#irf_tab span:hover { background-color: #F3F3F3; }' +
  471. '#irf_tab .irf_tab_selected, #irf_tab .irf_tab_selected:hover { background-color: #FFFFFF; border-bottom-color: #FFFFFF; }' +
  472. '#irf_form { padding: 8px 4px 4px 4px; border-top: 1px solid #999999; margin-top: 2px; }' +
  473. '#irf_form input[type="checkbox"], #irf_form input[type="radio"] { vertical-align: inherit; }' +
  474. '#irf_form input[type="checkbox"] { margin: 2px 4px 2px 0; }' +
  475. '#irf_form label { vertical-align: top; }' +
  476. '#irf_form textarea { margin: 0; width: 100%; height: 270px; }' +
  477. '#irf_form input, #irf_form textarea { color: black; }' +
  478. '#irf_form fieldset { padding: 4px; margin: 0 0 0.5em 0; border-color: #999; min-width: 490px; }' +
  479. '#irf_form fieldset:disabled > label { color: gray; }' +
  480. '#irf_form fieldset:disabled input, #irf_form fieldset:disabled textarea { color: #666666; background-color: #EEEEEE; }' +
  481. '#irf_form fieldset + fieldset { margin: 0.5em auto; }' +
  482. '#irf_form_hi, #irf_form_ad, #irf_form_etc { display: none; }' +
  483. '#irf_form_etc input[type="checkbox"] { margin: 2px 4px 2px 2px; }' +
  484. '.irf_form_add-row-button { text-align: right; }' +
  485. '.irf_form_add-row-input + .irf_form_add-row-caption, .irf_form_add-row-input + .irf_form_add-row-button { margin-top: 0.5em; }' +
  486. '.irf_form_add-row-textarea { margin-top: 1em; }' +
  487. '.inoreader_filter_hide + .irf_form_add-row-textarea { margin-top: 0; }' +
  488. '.irf_form_add-input { width: 95%; }' +
  489. '.irf_form_add-button:active { position:relative; top:1px; }' +
  490. '.irf_table_wrapper { max-height: 440px; overflow-y: scroll; }' +
  491. '.irf_table { display: table; width: 100%; }' +
  492. '.irf_tr { display: table-row; border: 1px solid red; }' +
  493. '.irf_tr:hover div { background-color: #EFEFEF; }' +
  494. '#irf_ad_sort { margin-left: 2em; font-weight: normal; }' +
  495. '#irf_ad_sort_type { padding: 0; margin-top: -4px; }' +
  496. '.irf_ad_td1, .irf_ad_td2 { display: table-cell; padding: 4px 2px; }' +
  497. '.irf_ad_td1 { max-width: 50em; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; }' +
  498. '.irf_ad_td2 { width: 5em; }' +
  499. '.irf_ad_td2 input { width: 4.8em; }' +
  500. '#irf_etc_key_settings { width: 7ex; text-align: center; margin: 0 0.5em; }' +
  501. '#irf_ok { margin-right: 0.5em; padding: 0 2em; }' +
  502. '#irf_cancel { padding: 0 1ex; }' +
  503. '#irf_ok, #irf_cancel { width: 8em; }' +
  504. '.irf_form_add-button { width: 12em; }' +
  505. '#irf_form textarea, .irf_form_add-input { width: -moz-available; width: -webkit-fill-available; width: available; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; box-sizing: border-box; }';
  506. if ($id('sb_rp_settings_menu')) {
  507. CSS += '.inoreader_filter_adarticle:before { font-family: "InoReader-UI-Icons-Font"; content: "\\e652"; padding-right: 5px; }';
  508. } else if ($id('read_articles_button')) {
  509. var img = $id('read_articles_button').firstChild;
  510. if (img && img.hasAttribute('src')) {
  511. CSS += '.inoreader_filter_adarticle:before { background: url("' + img.getAttribute('src') + '") no-repeat; content: " "; padding: 0 10px; }';
  512. }
  513. }
  514. GM_addStyle(CSS);
  515. var LOCALE_JA = {
  516. t00: '設定',
  517. t01: 'OK',
  518. t02: 'キャンセル',
  519. t03: 'NGワード',
  520. t04: 'ハイライト',
  521. t05: '広告記事',
  522. t06: 'その他',
  523. t07: 'フィード・フォルダ・タグ',
  524. t08: '記事タイトル',
  525. t09: '記事タイトル・記事概要・記事URL',
  526. t10: '記事概要・記事URL',
  527. t11: 'ルールを追加',
  528. t12: '削除',
  529. t13: '設定モード',
  530. t14: 'シンプル',
  531. t15: 'アドバンス',
  532. t16: '区切り文字',
  533. t17: 'コンソールにログを表示',
  534. t18: '選択記事をフォームに記入',
  535. t19: '累計',
  536. t20: 'ソート',
  537. t21: 'タイトル',
  538. t22: '登録日時',
  539. t23: '昇順',
  540. t24: '降順',
  541. t25: '新しい順',
  542. t26: '古い順',
  543. t27: 'ショートカットキー',
  544. t28: '設定欄の開閉',
  545. t29: 'キー',
  546. t30: '消去した記事が多すぎるので、InoReader Filterは記事を消去する機能を一時的に無効化しました。NGワードの設定を確認して下さい。'
  547. };
  548. var LOCALE_EN = {
  549. t00: 'Settings',
  550. t01: 'OK',
  551. t02: 'Cancel',
  552. t03: 'Exclude words',
  553. t04: 'Highlight words',
  554. t05: 'Advertising articles',
  555. t06: 'Etc',
  556. t07: 'Feed, folder, tag',
  557. t08: 'Article title',
  558. t09: 'Article title, summary, url',
  559. t10: 'Article summary, url',
  560. t11: 'Add rule',
  561. t12: 'Remove',
  562. t13: 'Setting mode',
  563. t14: 'Simple',
  564. t15: 'Advanced',
  565. t16: 'Delimiter',
  566. t17: 'View Log to console',
  567. t18: 'Fill in the selected article',
  568. t19: 'cumulative total',
  569. t20: 'Sort by',
  570. t21: 'Title',
  571. t22: 'Registered date',
  572. t23: 'A-Z',
  573. t24: 'Z-A',
  574. t25: 'newest',
  575. t26: 'oldest',
  576. t27: 'Shortcut keys',
  577. t28: 'Open/close the settings',
  578. t29: 'key',
  579. t30: 'Articles that was removed is too many. InoReader Filter has temporarily disabled the ability to remove the articles. Please check the settings of the exclude words.'
  580. };
  581. LOC = (window.navigator.language === 'ja') ? LOCALE_JA : LOCALE_EN;
  582.  
  583. var div = document.createElement('div');
  584. var html = '<div id="irf_titlebar"><div id="irf_title"><a href="https://userscripts.org/scripts/show/352673" target="_blank">InoReader Filter ' + LOC.t00 + '</a></div><div id="irf_title_btn"><input id="irf_ok" type="button" value="' + LOC.t01 + '" /><input id="irf_cancel" type="button" value="' + LOC.t02 + '" /></div></div><div id="irf_tab"><span id="irf_tab_ng" class="irf_tab_selected">' + LOC.t03 + '</span><span id="irf_tab_hi">' + LOC.t04 + '</span><span id="irf_tab_ad" class="irf_advance">' + LOC.t05 + '</span><span id="irf_tab_etc">' + LOC.t06 + '</span></div><div id="irf_form">';
  585. html += '<div id="irf_form_ng"><fieldset id="irf_ng_fs"><legend><label><input id="irf_ng_cb" type="checkbox" />' + LOC.t03 + '</label></legend><div class="irf_advance"><div class="irf_form_add-row-caption">' + LOC.t07 + ' :</div><div class="irf_form_add-row-input"><input id="irf_ng_add_feed" class="irf_form_add-input" type="input" /></div><div class="irf_form_add-row-caption">' + LOC.t08 + ' :</div><div class="irf_form_add-row-input"><input id="irf_ng_add_title" class="irf_form_add-input" type="input" /></div><div id="irf_ng_add_word-caption" class="irf_form_add-row-caption">' + LOC.t09 + ' :</div><div class="irf_form_add-row-input"><input id="irf_ng_add_word" class="irf_form_add-input" type="input" /></div><div class="irf_form_add-row-button"><input id="irf_ng_fill_bt" class="irf_form_fill-button" value="' + LOC.t18 + '" type="button" /><input id="irf_ng_add_bt" class="irf_form_add-button" value="' + LOC.t11 + '" type="button" /></div></div><div class="irf_form_add-row-textarea"><textarea id="irf_ng_ta"></textarea></div></fieldset></div>';
  586. html += '<div id="irf_form_hi"><fieldset id="irf_hi_fs"><legend><label><input id="irf_hi_cb" type="checkbox" />' + LOC.t04 + '</label></legend><div class="irf_advance"><div class="irf_form_add-row-caption">' + LOC.t07 + ' :</div><div class="irf_form_add-row-input"><input id="irf_hi_add_feed" class="irf_form_add-input" type="input" /></div><div class="irf_form_add-row-caption">' + LOC.t08 + ' :</div><div class="irf_form_add-row-input"><input id="irf_hi_add_title" class="irf_form_add-input" type="input" /></div><div id="irf_hi_add_word-caption" class="irf_form_add-row-caption">' + LOC.t09 + ' :</div><div class="irf_form_add-row-input"><input id="irf_hi_add_word" class="irf_form_add-input" type="input" /></div><div class="irf_form_add-row-button"><input id="irf_hi_fill_bt" class="irf_form_fill-button" value="' + LOC.t18 + '" type="button" /><input id="irf_hi_add_bt" class="irf_form_add-button" value="' + LOC.t11 + '" type="button" /></div></div><div class="irf_form_add-row-textarea"><textarea id="irf_hi_ta"></textarea></div></fieldset></div>';
  587. html += '<div id="irf_form_ad" class="irf_advance"><fieldset id="irf_ad_fs"><legend id="irf_ad_legend" title="' + LOC.t19 + ' : ' + st.adcount + '"><label><input id="irf_ad_cb" type="checkbox" />' + LOC.t05 + '</label><span id="irf_ad_sort">( ' + LOC.t20 + ' : <select id="irf_ad_sort_type"><option value="0">' + LOC.t21 + ' ( ' + LOC.t23 + ' )</option><option value="1">' + LOC.t21 + ' ( ' + LOC.t24 + ' )</option><option value="2">' + LOC.t22 + ' ( ' + LOC.t25 + ' )</option><option value="3">' + LOC.t22 + ' ( ' + LOC.t26 + ' )</option></select> )</span></legend><div id="irf_ad_table_wrapper" class="irf_table_wrapper"><div id="irf_ad_table" class="irf_table"></div></div></fieldset></div>';
  588. html += '<div id="irf_form_etc"><fieldset id="irf_etc_mode_fs"><legend>' + LOC.t13 + '</legend><label><input id="irf_etc_mode-s" name="irf_etc_mode_r" type="radio" value="simple" />' + LOC.t14 + '</label><label><input id="irf_etc_mode-a" name="irf_etc_mode_r" type="radio" value="advance" />' + LOC.t15 + '</label></fieldset><div class="irf_advance"><fieldset><legend>' + LOC.t27 + '</legend><label>' + LOC.t28 + ' : Ctrl+Shift+<input id="irf_etc_key_settings" type="text" maxlength="1" />' + LOC.t29 + '</label></fieldset><fieldset id="irf_etc_delimiter_fs"><legend>' + LOC.t16 + '</legend><input id="irf_etc_delimiter" type="input" /></fieldset><label><input id="irf_etc_log" type="checkbox">' + LOC.t17 + '</label></div></div>';
  589. html += '</div>';
  590. div.innerHTML = html;
  591. div.id = 'irf_settings';
  592. document.body.appendChild(div);
  593.  
  594. var menu = $id('sb_rp_settings_menu'),
  595. pqm = $id('preferences_quick_main'),
  596. item = document.createElement('div');
  597. item.id = 'irf_settings-menu';
  598. item.innerHTML = 'Filter ' + LOC.t00;
  599. if (menu) {
  600. item.className = 'inno_toolbar_button_menu_item';
  601. var menuList = menu.children;
  602. if (!menuList[menuList.length - 1].id) {
  603. var line = document.createElement('div');
  604. line.className = 'inno_toolbar_button_menu_line';
  605. menu.insertBefore(line, menu.lastChild.nextSibling);
  606. }
  607. menu.insertBefore(item, menu.lastChild.nextSibling);
  608. } else if ($id('quick_options') && pqm) {
  609. item.className = 'quick_options_link';
  610. pqm.insertBefore(item, pqm.lastChild.nextSibling);
  611. }
  612. if ($id('irf_settings-menu')) {
  613. $id('irf_settings-menu').addEventListener('click', function() {
  614. viewSettings();
  615. }, false);
  616. }
  617.  
  618. for (var i = 0, a; i < aAd.length; i++) {
  619. if (!aAd[i] || notType('Str', aAd[i]) || aAd[i].indexOf('<>') === -1) continue;
  620. a = aAd[i].slice(aAd[i].lastIndexOf('<>') + 2).split('@');
  621. if (a.length === 2 && (Date.now() > new Date(Number(a[0]) + (86400000 * 60)).getTime())) {
  622. if (st.log) GM_log('unregister ad: ' + aAd[i].slice(0, aAd[i].lastIndexOf('<>')));
  623. aAd.splice(i, 1);
  624. }
  625. }
  626. saveAddata(aAd);
  627.  
  628. var addRule = function(f, t, w) {
  629. var word = '';
  630. if (f) {
  631. word = f + st.delimiter;
  632. if (t) {
  633. word += t + st.delimiter;
  634. if (w) word += w;
  635. } else if (w) word += st.delimiter + w;
  636. } else if (t) {
  637. word = st.delimiter + t + st.delimiter;
  638. if (w) word += w;
  639. } else if (w) word = w;
  640. return word + '\n';
  641. };
  642.  
  643. var clickAddButton = function(s) {
  644. var sF = $id('irf_' + s + '_add_feed').value,
  645. sT = $id('irf_' + s + '_add_title').value,
  646. sW = $id('irf_' + s + '_add_word').value;
  647. if (!sT && !sW) return;
  648. var sData = $id('irf_' + s + '_ta').value,
  649. sRule = addRule(sF, sT, sW);
  650. if (sData.indexOf(sRule) === -1) {
  651. $id('irf_' + s + '_ta').value += (!sData || /(?:\r\n|\n|\r)$/.test(sData)) ? sRule : '\n' + sRule;
  652. }
  653. $id('irf_' + s + '_add_feed').value = '';
  654. $id('irf_' + s + '_add_title').value = '';
  655. $id('irf_' + s + '_add_word').value = '';
  656. $id('irf_' + s + '_add_word-caption').textContent = LOC.t09 + ' :';
  657. if (s === 'ng') {
  658. $id('irf_ng_add_bt').classList.add('inoreader_filter_hide');
  659. $id('irf_ng_fill_bt').classList.remove('inoreader_filter_hide');
  660. } else if (s === 'hi') {
  661. $id('irf_hi_add_bt').classList.add('inoreader_filter_hide');
  662. $id('irf_hi_fill_bt').classList.remove('inoreader_filter_hide');
  663. }
  664. };
  665.  
  666. var checkAd = function() {
  667. var eSa = $id('subscriptions_articles') || $id('reader_pane'),
  668. bUnregistered = true;
  669. if (!eSa) return;
  670. var eAc = currentExpandedArticle();
  671. if (!eAc.length) return;
  672. var sId = (eAc[0].id) ? eAc[0].id.slice(eAc[0].id.lastIndexOf('_') + 1) : '';
  673. if (!sId) return;
  674. var eTitle = $id('at_' + sId) || $id('article_title_link_' + sId),
  675. sTitle = (eTitle) ? eTitle.textContent : '';
  676. if (!sTitle) return;
  677. for (var i = 0, j = aAd.length; i < j; i++) {
  678. if (!aAd[i] || notType('Str', aAd[i]) || aAd[i].indexOf('<>') === -1) continue;
  679. if (sTitle === aAd[i].slice(0, aAd[i].lastIndexOf('<>'))) {
  680. bUnregistered = false;
  681. break;
  682. }
  683. }
  684. if (bUnregistered && reAd.test(sTitle)) {
  685. aAd.push(sTitle + '<>' + Date.now() + '@1');
  686. aAd.sort(function(a, b) {
  687. return a - b;
  688. });
  689. if ($id('at_' + sId)) $id('at_' + sId).classList.add('inoreader_filter_adarticle');
  690. if ($id('article_title_link_' + sId)) $id('article_title_link_' + sId).classList.add('inoreader_filter_adarticle');
  691. if (st.log) GM_log('register ad: ' + sTitle);
  692. saveAddata(aAd);
  693. st.adcount++;
  694. saveSettings(true);
  695. $id('irf_ad_legend').setAttribute('title', LOC.t19 + ' : ' + st.adcount);
  696. }
  697. };
  698.  
  699. var escRe = function(s) {
  700. return s.replace(/[.+\^=!:${}()|\[\]\/\\]/g, '\\$&');
  701. };
  702.  
  703. $id('irf_settings').addEventListener('click', function(e) {
  704. var tId = e.target.id;
  705. if (!tId) return;
  706. if (e.target.nodeName === 'INPUT' && e.target.getAttribute('type') === 'button') {
  707. e.target.blur();
  708. }
  709. if (tId === 'irf_ok') {
  710. var problem = false,
  711. delim = $id('irf_etc_delimiter').value,
  712. keyWin = $id('irf_etc_key_settings').value;
  713. st.ng = $id('irf_ng_cb').checked;
  714. st.ngdata = $id('irf_ng_ta').value;
  715. st.hi = $id('irf_hi_cb').checked;
  716. st.hidata = $id('irf_hi_ta').value;
  717. st.ad = $id('irf_ad_cb').checked;
  718. st.adsort = $id('irf_ad_sort_type').selectedIndex;
  719. if ($id('irf_etc_mode-s').checked) st.mode = 'simple';
  720. else if ($id('irf_etc_mode-a').checked) st.mode = 'advance';
  721. if (keyWin.length === 1) {
  722. if (/^[A-Za-z0-9]$/.test(keyWin)) st.keywindow = keyWin.toUpperCase();
  723. else {
  724. problem = true;
  725. setSettingsTab('etc');
  726. $id('irf_etc_key_settings').focus();
  727. }
  728. } else {
  729. $id('irf_etc_key_settings').value = 'F';
  730. st.keywindow = 'F';
  731. }
  732. if (delim) {
  733. if (/[.+\^=!:${}()|\[\]\/\\]/.test(delim)) {
  734. problem = true;
  735. setSettingsTab('etc');
  736. $id('irf_etc_delimiter').focus();
  737. } else st.delimiter = $id('irf_etc_delimiter').value;
  738. } else st.delimiter = '<>';
  739. st.log = $id('irf_etc_log').checked;
  740. if (!problem) {
  741. viewSettings();
  742. saveSettings();
  743. saveAddata((aAdTemp) ? aAdTemp : aAd);
  744. }
  745. } else if (tId === 'irf_cancel') {
  746. viewSettings();
  747. } else if (tId.indexOf('irf_tab_') !== -1) {
  748. var sId = tId.slice(tId.indexOf('irf_tab_') + 8);
  749. if (sId) setSettingsTab(sId);
  750. } else if (tId.indexOf('irf_etc_mode-') !== -1) {
  751. if (tId === 'irf_etc_mode-s') settingsMode('simple');
  752. else if (tId === 'irf_etc_mode-a') settingsMode('advance');
  753. } else if (/^irf_(?:ng|hi)_fill_bt$/.test(tId)) {
  754. var eAc = currentArticle(),
  755. sT = currentTreeName(),
  756. sF = '',
  757. sW = '';
  758. if (!eAc.length) return;
  759. var oA = articleData(eAc[0]);
  760. if (sT && oA.sFeed && sT !== oA.sFeed) sF = '/^' + escRe(sT) + '$|^' + escRe(oA.sFeed) + '$/';
  761. else if (sT) sF = sT;
  762. else if (oA.sFeed) sF = oA.sFeed;
  763. if (oA.sDesc) sW = '/^' + escRe(oA.sDesc) + '$|^' + escRe(oA.sUrl) + '$/';
  764. else sW = oA.sUrl;
  765. if (tId === 'irf_ng_fill_bt') {
  766. $id('irf_ng_add_feed').value = sF;
  767. $id('irf_ng_add_title').value = oA.sTitle;
  768. $id('irf_ng_add_word').value = sW;
  769. $id('irf_ng_add_bt').classList.remove('inoreader_filter_hide');
  770. $id('irf_ng_fill_bt').classList.add('inoreader_filter_hide');
  771. } else if (tId === 'irf_hi_fill_bt') {
  772. $id('irf_hi_add_feed').value = sF;
  773. $id('irf_hi_add_title').value = oA.sTitle;
  774. $id('irf_hi_add_word').value = sW;
  775. $id('irf_hi_add_bt').classList.remove('inoreader_filter_hide');
  776. $id('irf_hi_fill_bt').classList.add('inoreader_filter_hide');
  777. }
  778. } else if (tId === 'irf_ng_add_bt') {
  779. clickAddButton('ng');
  780. } else if (tId === 'irf_hi_add_bt') {
  781. clickAddButton('hi');
  782. } else if (/^irf_ad_switch_|^irf_ad_remove_/.test(tId)) {
  783. if (!aAdTemp) aAdTemp = aAd.concat();
  784. for (var i = 0, j = aAdTemp.length, a, t, d; i < j; i++) {
  785. if (!aAdTemp[i] || notType('Str', aAdTemp[i]) || aAdTemp[i].indexOf('<>') === -1) continue;
  786. t = aAdTemp[i].slice(0, aAdTemp[i].lastIndexOf('<>'));
  787. a = aAdTemp[i].slice(aAdTemp[i].lastIndexOf('<>') + 2).split('@');
  788. d = (a.length === 2 && Number(a[0]) >= 0) ? a[0] : '';
  789. if (d && tId.slice(14) === d) {
  790. if (/^irf_ad_switch_/.test(tId)) {
  791. aAdTemp[i] = aAdTemp[i].replace(/@\d$/, '@' + (a[1] === '1' ? '0' : '1'));
  792. } else if (/^irf_ad_remove_/.test(tId)) {
  793. aAdTemp.splice(i, 1);
  794. }
  795. createAdtable($id('irf_ad_sort_type').selectedIndex, true);
  796. break;
  797. }
  798. }
  799. }
  800. }, false);
  801.  
  802. $id('irf_ng_cb').addEventListener('click', function(e) {
  803. if (e.target.checked) $id('irf_ng_fs').removeAttribute('disabled');
  804. else $id('irf_ng_fs').setAttribute('disabled', '');
  805. }, false);
  806.  
  807. $id('irf_hi_cb').addEventListener('click', function(e) {
  808. if (e.target.checked) $id('irf_hi_fs').removeAttribute('disabled');
  809. else $id('irf_hi_fs').setAttribute('disabled', '');
  810. }, false);
  811.  
  812. $id('irf_titlebar').addEventListener('dblclick', function(e) {
  813. if (e.target.nodeName === 'DIV') {
  814. $id('irf_tab').classList.toggle('inoreader_filter_hide');
  815. $id('irf_form').classList.toggle('inoreader_filter_hide');
  816. $id('irf_title_btn').classList.toggle('inoreader_filter_hide');
  817. }
  818. }, false);
  819.  
  820. $id('irf_settings').addEventListener('input', function(e) {
  821. if (e.target.id === 'irf_ng_add_title') {
  822. if (e.target.value) $id('irf_ng_add_word-caption').textContent = LOC.t10 + ' :';
  823. else $id('irf_ng_add_word-caption').textContent = LOC.t09 + ' :';
  824. } else if (e.target.id === 'irf_hi_add_title') {
  825. if (e.target.value) $id('irf_hi_add_word-caption').textContent = LOC.t10 + ' :';
  826. else $id('irf_hi_add_word-caption').textContent = LOC.t09 + ' :';
  827. }
  828. if ($id('irf_tab_ng').classList.contains('irf_tab_selected')) {
  829. if ($id('irf_ng_add_feed').value || $id('irf_ng_add_title').value || $id('irf_ng_add_word').value) {
  830. $id('irf_ng_add_bt').classList.remove('inoreader_filter_hide');
  831. $id('irf_ng_fill_bt').classList.add('inoreader_filter_hide');
  832. } else {
  833. $id('irf_ng_add_bt').classList.add('inoreader_filter_hide');
  834. $id('irf_ng_fill_bt').classList.remove('inoreader_filter_hide');
  835. }
  836. } else if ($id('irf_tab_hi').classList.contains('irf_tab_selected')) {
  837. if ($id('irf_hi_add_feed').value || $id('irf_hi_add_title').value || $id('irf_hi_add_word').value) {
  838. $id('irf_hi_add_bt').classList.remove('inoreader_filter_hide');
  839. $id('irf_hi_fill_bt').classList.add('inoreader_filter_hide');
  840. } else {
  841. $id('irf_hi_add_bt').classList.add('inoreader_filter_hide');
  842. $id('irf_hi_fill_bt').classList.remove('inoreader_filter_hide');
  843. }
  844. }
  845. }, false);
  846.  
  847. $id('irf_ad_sort_type').addEventListener('change', function() {
  848. createAdtable($id('irf_ad_sort_type').selectedIndex);
  849. }, false);
  850.  
  851. $id('reader_pane').addEventListener('click', function() {
  852. checkAd();
  853. }, false);
  854.  
  855. document.addEventListener('keyup', function(e) {
  856. if (e.ctrlKey && e.shiftKey && e.keyCode === st.keywindow.charCodeAt()) viewSettings();
  857. else if (/input|textarea/i.test(e.target.tagName)) return;
  858. checkAd();
  859. }, true);
  860.  
  861. mutation();
  862. observer.observe(target, config);
  863. };
  864.  
  865. iInit = window.setInterval(function() {
  866. if ($id('tree') && $id('tree').innerHTML) {
  867. window.clearInterval(iInit);
  868. init();
  869. }
  870. }, 500);
  871.  
  872. })();