Greasy Fork镜像 还支持 简体中文。

InoReader Filter

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

目前為 2014-10-13 提交的版本,檢視 最新版本

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址