InoReader Full Feed

Read full story in InoReader. / InoReaderで記事の全文を表示します。

当前为 2018-03-25 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name InoReader Full Feed
  3. // @description Read full story in InoReader. / InoReaderで記事の全文を表示します。
  4. // @description:en Read full story in InoReader.
  5. // @description:ja InoReaderで記事の全文を表示します。
  6. // @id InoReaderFullFeed
  7. // @namespace https://userscripts.org/scripts/show/172238
  8. // @homepage https://greasyfork.org/scripts/897-inoreader-full-feed
  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://jp.inoreader.com/*
  14. // @include https://jp.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. // @connect *
  20. // @grant GM_addStyle
  21. // @grant GM_openInTab
  22. // @grant GM_registerMenuCommand
  23. // @grant GM_setClipboard
  24. // @grant GM_xmlhttpRequest
  25. // @noframes
  26. // @version 1.06
  27. // ==/UserScript==
  28.  
  29. (function() {
  30. 'use strict';
  31.  
  32. var version = 1.06;
  33.  
  34. // == [CSS] =====================================
  35. var CSS =
  36. '#subscriptions_articles .article_content a { color: #0069D6; }' +
  37. '#subscriptions_articles .article_content a:hover { color: #0064CD; text-decoration: underline; }' +
  38. '#subscriptions_articles .article_content a:visited { color: #0069D6; }' +
  39. '#subscriptions_articles .article_title img { border: none; vertical-align: text-top; }' +
  40. '#subscriptions_articles .article_title span a { margin: 0 3px; }' +
  41. '#subscriptions_articles .article_content .clear { font-size: inherit !important; height: auto !Important; width: auto !important; }' +
  42. '.irff_loading { border-color: limegreen !important; }' +
  43. '.irff_loaded * { position: static !important; }' +
  44. '.irff_opened { border-color: gold !important; }' +
  45. '.irff_ap_on { color: #009900; }' +
  46. '.irff_ap_off { color: #990000; }' +
  47. '.irff_pager { margin: 3em 0; }' +
  48. '.irff_pager hr { margin-bottom: 5px; }' +
  49. '.irff_pager_differenthost { margin-left: 2em; font-weight: bold; }' +
  50. '.irff_entry_url a { padding-left: 12px; }' +
  51. '.irff_hidden { display: none; }' +
  52. '#irff_message { position: fixed; top: 4px; right: 250px; z-index: 90900; color: black; background-color: #FFEEAA; box-shadow: 1px 1px 2px #CCCCCC; padding: 4px 8px; }' +
  53. '.irff_warning { background-color: #FF9999 !important; }' +
  54. '.irff_checked { margin-right: 4px; }' +
  55. '.irff_checked_icon { color: white; font-size: 0.8em; margin-left: 0.5em; padding: 0 4px; text-decoration:none; cursor: pointer; position: relative; top: 0.3em; vertical-align: top; border-radius: 3px; box-shadow: 1px 1px 2px #CCCCCC; }' +
  56. '.irff_checked_icon:active { box-shadow: none; }' +
  57. '.irff_checked_icon_info { background: #FFCC00; background: linear-gradient(top, #FFCC00, #FF9900); border: 1px solid #EE8800; }' +
  58. '.irff_checked_icon_info:hover { background: #FFEE00; background: linear-gradient(top, #FFEE00, #FFBB00); border: 1px solid #EEAA00; }' +
  59. '.irff_checked_icon_noinfo { background: #CCCCCC; background: linear-gradient(top, #CCCCCC, #999999); border: 1px solid #888888; }' +
  60. '.irff_checked_icon_noinfo:hover { background: #EEEEEE; background: linear-gradient(top, #EEEEEE, #BBBBBB); border: 1px solid #AAAAAA; }' +
  61. '.irff_checked_icon_next { background: #77CC77; background: linear-gradient(top, #77CC77, #55AA55); border: 1px solid #449944; }' +
  62. '.irff_checked_icon_next:hover { background: #99EE99; background: linear-gradient(top, #99EE99, #77CC77); border: 1px solid #66BB66; }' +
  63. '.irff_checked_icon_nonext { background: #BBEEBB; background: linear-gradient(top, #BBEEBB, #99CC99); border: 1px solid #88BB88; }' +
  64. '.irff_checked_icon_nonext:hover { background: #DDFFDD; background: linear-gradient(top, #DDFFDD, #BBEEBB); border: 1px solid #AADDAA; }' +
  65. '.irff_checked_icon_as_next { background: #7777CC; background: linear-gradient(top, #7777CC, #5555AA); border: 1px solid #444499; }' +
  66. '.irff_checked_icon_as_next:hover { background: #9999EE; background: linear-gradient(top, #9999EE, #7777CC); border: 1px solid #6666BB; }' +
  67. '.irff_checked_icon_as_nonext { background: #BBBBEE; background: linear-gradient(top, #BBBBEE, #9999CC); border: 1px solid #8888BB; }' +
  68. '.irff_checked_icon_as_nonext:hover { background: #DDDDFF; background: linear-gradient(top, #DDDDFF, #BBBBEE); border: 1px solid #AAAADD; }' +
  69. '.irff_socialicon { font-size: 12px; vertical-align: middle; }' +
  70. '#irff_s { color: black; background: rgba(255, 255, 255, 0.98); z-index: 90000; position: absolute; top: 8px; left: 8px; padding: 0; min-width: 20em; border: 1px solid #999999; border-radius: 4px; box-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2); -moz-user-select: none; -webkit-user-select: none; user-select: none; }' +
  71. '#irff_s input[type="text"], input[type="number"], #irff_s textarea { color: black; padding: 0 2px; }' +
  72. '#irff_s input[type="button"] { font-size: 90%; cursor: pointer; }' +
  73. '#irff_s select { font-size: 100%; padding: 1px 2px; }' +
  74. '#irff_s fieldset { border: 1px solid #999999; #FFCC66; margin: 4px 2px; background: none !important; }' +
  75. '#irff_s fieldset > fieldset { margin: 0; }' +
  76. '#irff_s fieldset, #irff_s input[type="text"], #irff_s input[type="number"], #irff_s textarea, #irff_s select { color: black; background-color: transparent; }' +
  77. '#irff_s-titlebar { padding: 0 4px 8px 4px; background-color: #666666; }' +
  78. '#irff_s-titlebar_title { position: relative; top: 3px; }' +
  79. '#irff_s-titlebar_title a { color: white; text-decoration: none; font-weight: bold; }' +
  80. '#irff_s-titlebar_button { position: absolute; top: 0; right: 4px; }' +
  81. '#irff_s-titlebar input { margin: 0 4px; width: 8em; }' +
  82. '#irff_s-tab { padding: 0 0.5em; margin-top: 1em; }' +
  83. '#irff_s-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; }' +
  84. '#irff_s-tab span:hover { background-color: #F3F3F3; }' +
  85. '#irff_s-tab .select, #irff_s-tab .select:hover { background-color: #FFFFFF; background-image: none; border-bottom-color: #FFFFFF; }' +
  86. '.irff_s-title { float: left; padding: 4px 8px; margin: 0; color: #224488; cursor: pointer; text-decoration: underline; font-size: 100%; }' +
  87. '#irff_s-list { padding: 8px 4px 4px 4px; border-top: 1px solid #999999; margin: 3px 0 0 0; min-width: 590px; }' +
  88. '#irff_s-list input[type="checkbox"], #irff_s-list input[type="radio"] { vertical-align: middle; margin: 5px 4px; }' +
  89. '#irff_s-footer { text-align: right; padding: 4px; }' +
  90. '.irff_s-footer input { margin: 0 4px; }' +
  91. '#irff_s-ok { padding: 0 2em; }' +
  92. '.irff_s-addbutton { margin-left: 8px; width: 6em; }' +
  93. '.irff_s-hide { display: none; }' +
  94. '.irff_s-r + .irff_s-r { margin-left: 1.5em; }' +
  95. '.irff_s-f_column2 { float: left; width: 271px; }' +
  96. '.irff_s-clearfix:after { clear: both; content: ""; display: block; }' +
  97. '.irff_s-table { display: table; width: 100%; }' +
  98. '.irff_s-table > *:not(datalist) { display: table-cell; }' +
  99. '#irff_s-general_key, #irff_s-general_apheight, #irff_s-etc_timeout { width: 5em; text-align: center; margin-right: 1ex; ime-mode: disabled; }' +
  100. '#irff_s-general_keyhelpicon { margin-left: 1em; }' +
  101. '#irff_s-general_keyhelpbody { margin-top: 0.5em; display: none; }' +
  102. '#irff_s-general_cantdisplay { margin-bottom: 0.5em; }' +
  103. '#irff_s-general_notread { width: 536px; margin-bottom: 0.8em;}' +
  104. '#irff_s-siteinfo_navi, #irff_s-autoload_navi { margin: 0.5em 0 1em 1em; }' +
  105. '.irff_s-navi span { padding: 0.25em 0.75em; border-width: 2px 1px; border-style: solid; border-color: #CFCFCF #C9C9C9 #C3C3C3; background-color: #F6F6F6; background-image: -webkit-linear-gradient(#FFFFFF, #F0F0F0); background-image: linear-gradient(#FFFFFF, #F0F0F0); }' +
  106. '.irff_s-navi span:hover { border-bottom-color: #FFE0A2; }' +
  107. '.irff_s-navi span:first-of-type, #irff_s-siteinfo_navi > .irff_hidden + span:not(.irff_hidden) { border-radius: 4px 0 0 4px; border-width: 2px 1px 2px 2px; }' +
  108. '.irff_s-navi span:last-of-type, #irff_s-siteinfo_navi > .irff_hidden + span:not(.irff_hidden) + span { border-radius: 0 4px 4px 0; border-width: 2px 2px 2px 1px; }' +
  109. '.irff_s-navi .select { border-color: #C3C3C3 #C9C9C9 #FFCC66; background-color: white; background-image: -webkit-linear-gradient(#F6F6F6, #FFFFFF); background-image: linear-gradient(#F6F6F6, #FFFFFF); }' +
  110. '.irff_s-siteinfo_navi, .irff_s-autoload_navi { color: #224488; padding: 0 0.5em; cursor: pointer; }' +
  111. '#irff_s-siteinfo fieldset, #irff_s-autoload fieldset { display: none; }' +
  112. '#irff_s-siteinfo fieldset.select, #irff_s-autoload fieldset.select { display: block; }' +
  113. '#irff_s-siteinfo textarea { width: 560px; min-width: 560px; height: 8em; min-height: 4em; }' +
  114. '.irff_s-siteinfo_form > div { margin-bottom: 4px; }' +
  115. '#irff_s-siteinfo_uap_pageelement_label { }' +
  116. '.irff_s-siteinfo_text { width: 100%; box-sizing: border-box; }' +
  117. '#irff_s-siteinfo_uff_type_label { width: 18em; }' +
  118. '.irff_s-addbutton_span { width: 6em; }' +
  119. '.irff_s-siteinfo_user_label > span { margin-top: 4px; }' +
  120. '.irff_s-siteinfo_user_label:not(.irff_s-table) > span { display: inline-block; }' +
  121. '#irff_s-siteinfo_f_uff .irff_s-siteinfo_user_label > span, #irff_s-siteinfo_uff_enc_span { width: 3.5em; }' +
  122. '#irff_s-siteinfo_f_uap .irff_s-siteinfo_user_label > span, #irff_s-siteinfo_uap_pageelement_span { width: 7em; }' +
  123. '#irff_s-siteinfo_user_label_enc { margin-left: 24px; }' +
  124. '#irff_s-siteinfo_user_label_enc > span { margin-right: 8px; }' +
  125. '#irff_s-autoload fieldset, #irff_s-autoload input[type="radio"] { margin-bottom: 0.5em; }' +
  126. '.irff_s-autoload_form { display: none; }' +
  127. '.irff_s-autoload_form.select { display: block; }' +
  128. '.irff_s-autoload_title { width: 100%; }' +
  129. '.irff_s-autoload_list { width: 560px; min-width: 560px; height: 8em; min-height: 4em; margin-top: 8px; }' +
  130. '#irff_s-siteinfo_disableitemlist { width: 560px; overflow: hidden; white-space: nowrap; }' +
  131. '#irff_s-etc input[type="button"] { margin: 0 4px; letter-spacing: 1px; }' +
  132. '.irff_siteinfourl_list fieldset { background-color: #FFF7D7; }' +
  133. '#irff_s-security input[type="text"], #irff_s-etc input[type="text"] { width: 560px; }' +
  134. '#irff_temp { background-color: gray; border: 2px solid gray; border-radius: 4px; left: 100px; position: fixed; top: 190px; visibility: hidden; width: 400px; z-index: 91000; }' +
  135. '#irff_temp-bar_title { color: white; font-weight: bold; padding: 0 4px; position: relative; top: 3px; }' +
  136. '#irff_temp-bar_button { position: absolute; right: 0; top: 0; }' +
  137. '#irff_temp-body { margin-top: 9px; }' +
  138. '#irff_temp-close { text-align: center; width: 100px; }' +
  139. '#irff_temp-textarea { height: 200px; width: 395px; }' +
  140. '.irff_twitter, .irff_delicious, .irff_facebook, .irff_hatena { position: relative; top: -2px; padding: 2px 4px; }' +
  141. '.irff_twitter img, .irff_delicious img, .irff_facebook img, .irff_hatena img { width: 16px; height: 16px; }' +
  142. '.irff_twitter span, .irff_delicious span, .irff_facebook span, .irff_hatena span { padding: 0px 3px; }' +
  143. '.irff_twitter1 span { color: #33CCFF !important; }' +
  144. '.irff_twitter2 span { color: #22AAFF !important; }' +
  145. '.irff_twitter3 span { color: #1188FF !important; }' +
  146. '.irff_twitter4 span { color: #0066FF !important; }' +
  147. '.irff_delicious span { color: white !important; }' +
  148. '.irff_delicious1 span { background-color: #73ADFF !important; }' +
  149. '.irff_delicious2 span { background-color: #5592E9 !important; }' +
  150. '.irff_delicious3 span { background-color: #3274D0 !important; }' +
  151. '.irff_delicious4 span { background-color: #2261A0 !important; }' +
  152. '.irff_hatena1 span { color: #FF6563 !important; background-color: #FFF0F0 !important; }' +
  153. '.irff_hatena2 span { color: #FF4444 !important; background-color: #FFEEEE !important; }' +
  154. '.irff_hatena3 span { color: #FF2222 !important; background-color: #FFDDDD !important; }' +
  155. '.irff_hatena4 span { color: #FF0000 !important; background-color: #FFCCCC !important; }';
  156.  
  157. // == [Locale] ==================================
  158. var LOCALE_JA = {
  159. t0: '全文を読み込み中..',
  160. t1: '全文を読み込み中 Auto Search..',
  161. t2: '全文を読み込み中..... 完了',
  162. t3: 'SITEINFOが古いか間違っているので代わりにReadabilityで読み込みます',
  163. t4: '次のページを読み込み中..',
  164. t5: '次のページを読み込み中..... 完了',
  165. t6: '最後のページを読み込み中..... 完了',
  166. t7: '次のページは見つかりません',
  167. t8: '読み込みをブロックしました',
  168. t9: 'すでに全文を読み込みました',
  169. t10: 'SITEINFOが見つからないので新しいタブで開きました',
  170. t11: 'キャッシュをリセットしています..',
  171. t12: 'キャッシュをリセットしています..... 完了',
  172. t13: 'ポップアップできません',
  173. t14: 'エラー:サーバーからキャッシュを読み込めませんでした',
  174. t15: 'キャッシュをリセットしますか?',
  175. t16: 'キャッシュを消去しますか?',
  176. t17: 'エラー:JSONPはサポートしていません',
  177. t18: '全文読み込み',
  178. t19: '正規表現',
  179. t20: '追加',
  180. t21: '設定',
  181. t22: 'キャンセル',
  182. t23: 'ショートカットキー',
  183. t24: 'キー',
  184. t25: 'キーコード',
  185. t26: 'Auto Load 切替',
  186. t27: 'AutoPagerize 切替',
  187. t28: '設定欄を表示',
  188. t29: 'キャッシュリセット',
  189. t30: 'Full Feed URL',
  190. t31: 'AutoPagerize URL',
  191. t32: 'Full Feed ユーザー SITEINFO',
  192. t33: 'AutoPagerize ユーザー SITEINFO',
  193. t34: '次のページを読み込み中 Auto Search..... 完了',
  194. t35: '最後のページを読み込み中 Auto Search..... 完了',
  195. t36: 'すべて',
  196. t37: 'フィードタイトル',
  197. t38: '記事タイトル',
  198. t39: 'ホワイトリスト/ブラックリストに追加',
  199. t40: 'クリック',
  200. t41: '次のページを読み込む',
  201. t42: 'noscriptタグ内のコンテンツを表示',
  202. t43: '自動的に全文を読み込むアイテム',
  203. t44: 'ホワイトリスト',
  204. t45: 'ホワイトリストのみ',
  205. t46: 'なし',
  206. t47: '全文を読み込まないアイテム',
  207. t48: '読み込まない代わりに新しいタブで開く',
  208. t49: '新しいタブで開きました',
  209. t50: 'デバッグログをコンソールに出力',
  210. t51: '全文を読み込み中 Auto Search..... 完了',
  211. t52: 'インラインフレームを取り除く',
  212. t53: 'エラー:dom.storage.enabledをtrueに設定してください',
  213. t54: 'お待ちください',
  214. t55: 'ソーシャルアイコンを表示',
  215. t56: 'Yahoo!ブックマーク',
  216. t57: 'Buzzurl [バザール]',
  217. t58: 'はてなブックマーク',
  218. t59: '警告:次ページを継ぎ足してもよろしいですか?\n\n今のページ:',
  219. t60: '\n次のページ:',
  220. t61: '次ページを継ぎ足しません',
  221. t62: '次ページの継ぎ足しを許可するURL',
  222. t63: '次ページの継ぎ足しを禁止するURL',
  223. t64: 'SITEINFOがなくても全文の読み込みを試みる',
  224. t65: '表示を許可するインラインフレームのソースURL',
  225. t66: '設定をエクスポートしてクリップボードへコピーしますか?',
  226. t67: 'クリップボードへコピーしました',
  227. t68: '設定をエクスポートしました。\n以下の文字列をコピーしてください\n\n',
  228. t69: 'エクスポートした文字列を入力してください',
  229. t70: '設定をインポートしました',
  230. t71: 'インポートできません',
  231. t72: '設定をリセットしますか?',
  232. t73: '設定をリセットしました',
  233. t74: 'SITEINFOが見つからないので代わりにReadabilityで読み込みます',
  234. t75: '全文を表示できないとき',
  235. t76: 'ブラックリスト',
  236. t77: 'ブラックリスト以外',
  237. t78: '設定モード',
  238. t79: 'シンプル',
  239. t80: 'アドバンス',
  240. t81: '秒',
  241. t82: 'リクエストを中断しました',
  242. t83: 'Readabilityで読み込む',
  243. t84: '新しいタブで開く',
  244. t85: '何もしない',
  245. t86: 'SITEINFOが見つからないため全文を表示できませんでした',
  246. t87: 'インラインフレームで表示する',
  247. t88: 'SITEINFOが見つからないのでインラインフレームで表示します',
  248. t89: '埋め込みツイートを変換する'
  249. };
  250. var LOCALE_EN = {
  251. t0: 'Loading Full Feed..',
  252. t1: 'Loading Full Feed Auto Search.....',
  253. t2: 'Loading Full Feed..... Done',
  254. t3: 'SITEINFO is unmatched to this entry, Load article from Readability',
  255. t4: 'Loading next page..',
  256. t5: 'Loading next page..... Done',
  257. t6: 'Loading last page..... Done',
  258. t7: 'Next page is not found',
  259. t8: 'Blocked loading full story',
  260. t9: 'This entry has been already loaded',
  261. t10: 'SITEINFO is not found, Opened in new tab',
  262. t11: 'Resetting cache. Please wait..',
  263. t12: 'Resetting cache. Please wait..... Done',
  264. t13: 'Cannot popup',
  265. t14: 'Cache Request Error',
  266. t15: 'Reset cache?',
  267. t16: 'Delete cache?',
  268. t17: 'Error: not support JSONP',
  269. t18: 'read full story',
  270. t19: 'regular expression',
  271. t20: 'Add',
  272. t21: 'Settings',
  273. t22: 'Cancel',
  274. t23: 'shortcut key',
  275. t24: 'key',
  276. t25: 'key code',
  277. t26: 'change Auto Load',
  278. t27: 'change AutoPagerize',
  279. t28: 'view settings',
  280. t29: 'reset cache',
  281. t30: 'Full Feed URL',
  282. t31: 'AutoPagerize URL',
  283. t32: 'Full Feed user SITEINFO',
  284. t33: 'AutoPagerize user SITEINFO',
  285. t34: 'Loading next page Auto Search..... Done',
  286. t35: 'Loading last page Auto Search..... Done',
  287. t36: 'All',
  288. t37: 'Feed title',
  289. t38: 'Article title',
  290. t39: 'Add whitelist/blacklist',
  291. t40: 'Click',
  292. t41: 'Loading next page',
  293. t42: 'Display content in noscript tags',
  294. t43: 'Read full story automatically',
  295. t44: 'Whitelist',
  296. t45: 'Whitelist only',
  297. t46: 'None',
  298. t47: 'Item which does not read full story',
  299. t48: 'Instead of not reading, open article in new tab',
  300. t49: 'Opened article in new tab',
  301. t50: 'Debug log to the browser console',
  302. t51: 'Loading Full Feed Auto Search..... Done',
  303. t52: 'Remove iframe',
  304. t53: 'Error: Please set "dom.storage.enabled" in "true".',
  305. t54: 'Wait',
  306. t55: 'Display social icon',
  307. t56: 'Yahoo! JAPAN Bookmarks',
  308. t57: 'Buzzurl',
  309. t58: 'Hatena Bookmark',
  310. t59: 'Warning: Add the next page?\n\nreading page: ',
  311. t60: '\nnext page: ',
  312. t61: 'Do not add the next page',
  313. t62: 'URL to allow the addition of the next page',
  314. t63: 'URL to deny the addition of the next page',
  315. t64: 'Try loading full story without SITEINFO',
  316. t65: 'The source URL of the inline frame to display',
  317. t66: 'Export settings and copy it to clipboard?',
  318. t67: 'Copied it to clipboard',
  319. t68: 'Exported settings.\nPlease copy the following character string\n\n',
  320. t69: 'Please input the character string that exported',
  321. t70: 'Imported settings',
  322. t71: 'Cannot import',
  323. t72: 'Reset settings?',
  324. t73: 'Reset settings',
  325. t74: 'SITEINFO is not found, Load article from Readability',
  326. t75: 'If cannot display full story',
  327. t76: 'blacklist',
  328. t77: 'Except blacklist',
  329. t78: 'Settings mode',
  330. t79: 'Simple',
  331. t80: 'Advanced',
  332. t81: 'seconds',
  333. t82: 'Aborted request',
  334. t83: 'load article from Readability',
  335. t84: 'open article in new tab',
  336. t85: 'do nothing',
  337. t86: 'Site info to display full story is not found',
  338. t87: 'display article in iframe',
  339. t88: 'SITEINFO is not found, Display article in iframe',
  340. t89: 'Convert Embedded Tweets'
  341. };
  342. var LOC = (window.navigator.language === 'ja') ? LOCALE_JA : LOCALE_EN;
  343.  
  344. // == [Application] =============================
  345. try {
  346. if (typeof localStorage !== 'object') return window.alert(LOC.t53);
  347. } catch (e) {
  348. return window.alert(LOC.t53);
  349. }
  350. var $id = function(id) {
  351. return document.getElementById(id);
  352. };
  353. var $ids = function(id) {
  354. return $id(`irff_s-${id}`);
  355. };
  356.  
  357. var FullFeed = function(info, c, flag) {
  358. state = 'ready';
  359. this.itemInfo = c;
  360. this.info = info;
  361. this.requestURL = this.itemInfo.itemURL;
  362. var u = this.requestURL;
  363. if (/^http:\/\/rd\.yahoo\.co\.jp\/rss\/l\/.+/.test(u)) {
  364. if (/\/\*-http/.test(u)) this.requestURL = decodeURIComponent(u.slice(u.indexOf('*-http') + 2));
  365. else if (/\/\*http/.test(u)) this.requestURL = decodeURIComponent(u.slice(u.indexOf('*http') + 1));
  366. }
  367. this.itemInfo.itemBody = document.querySelector(`${currentEntry()} .article_content`);
  368. var encode = this.info.enc || document.characterSet;
  369. if (flag === 'next' && this.itemInfo.innerContents) {
  370. this.itemInfo.innerContents.className.split(/\s+/).some(i => {
  371. if (!/^entry|^gm_|^http/.test(i)) {
  372. encode = i;
  373. return true;
  374. }
  375. });
  376. }
  377. this.mime = `text/html; charset=${encode}`;
  378. if (flag === 'search') this.request('HEAD', c);
  379. else this.request('GET', c);
  380. if (debugLog) {
  381. try {
  382. console.log(new Date());
  383. console.log('Item Title: ', c.item.title);
  384. console.log('Item URL: ', c.item.url);
  385. console.log('Feed URL: ', c.feed.url);
  386. console.log('FullFeed URL: ', info.url);
  387. console.log('FullFeed XPath: ', info.xpath);
  388. console.log('FullFeed Encode: ', info.enc);
  389. console.log(this.info);
  390. } catch (e) { console.error(e); }
  391. }
  392. };
  393.  
  394. FullFeed.prototype.request = function(m, c) {
  395. if (!this.requestURL) return;
  396. state = 'request';
  397. var self = this,
  398. retry = 0,
  399. mes = '',
  400. xhrID;
  401. var message2 = function(s, d, t) {
  402. mes = s;
  403. message(s, d, t);
  404. };
  405. var gmRequest = function() {
  406. xhr.push(GM_xmlhttpRequest(opt));
  407. xhrID = window.setTimeout(() => {
  408. window.clearTimeout(xhrID);
  409. for (var x1 = 0, x2 = xhr.length; x1 < x2; x1++) {
  410. if (xhr[x1]) xhr[x1].abort();
  411. }
  412. xhr.length = 0;
  413. state = null;
  414. message(LOC.t82, 3000, 'warning');
  415. }, st.timeout * 1000);
  416. };
  417. var opt = {
  418. method: m,
  419. url: this.requestURL,
  420. overrideMimeType: this.mime,
  421. timeout: st.timeout * 1000,
  422. onreadystatechange: function(res) {
  423. var dot = '';
  424. if (res.readyState >= 1 && res.readyState <= 3) {
  425. for (var i = 0; i < res.readyState; i++) dot += '.';
  426. message(mes + dot, -1);
  427. }
  428. },
  429. onerror: function() {
  430. window.clearTimeout(xhrID);
  431. state = null;
  432. self.requestError.apply(self, ['Request Error']);
  433. },
  434. onload: function(res) {
  435. window.clearTimeout(xhrID);
  436. if ((res.status >= 301 && res.status <= 303) || res.status === 307) {
  437. try {
  438. opt.url = /\sLocation:\s+(\S+)/.exec(res.responseHeaders)[1];
  439. gmRequest();
  440. return;
  441. } catch (er) {
  442. state = null;
  443. self.requestError.apply(self, [`Request Error : ${res.status}`]);
  444. return;
  445. }
  446. } else if (res.status === 200) {
  447. if (res.finalUrl) opt.url = this.requestURL = res.finalUrl;
  448. readingPageUrl = c.innerContents.className.split(/\s+/).filter(i => /^http/.test(i)).slice(-1);
  449. readingPageUrl = (readingPageUrl.length) ? readingPageUrl.toString() : opt.url;
  450. var cset = /content-type:\s?\S+\s?charset=\S+/i.exec(res.responseHeaders),
  451. enc = self.info.enc || '';
  452. if (cset) cset = cset[0].slice(cset[0].lastIndexOf('=') + 1);
  453. if (opt.method === 'GET') {
  454. if (cset && !new RegExp(cset, 'i').test(enc) && retry < 2) {
  455. self.info.enc = cset;
  456. opt.overrideMimeType = `text/html; charset=${cset}`;
  457. gmRequest();
  458. retry += 1;
  459. } else {
  460. var h1 = readingPageUrl.split('/')[2],
  461. h2 = opt.url.split('/')[2],
  462. re = new RegExp(st.allownexturl, 'i');
  463. if (h1 === h2 || (st.allownexturl && re.test(readingPageUrl))) self.requestLoad.call(self, res, c);
  464. else if (window.confirm(LOC.t59 + readingPageUrl + LOC.t60 + opt.url)) self.requestLoad.call(self, res, c);
  465. else self.requestEnd(c, false, true);
  466. }
  467. } else if (opt.method === 'HEAD') {
  468. if (cset && st.autosearch) {
  469. self.info.enc = cset;
  470. opt.method = 'GET';
  471. opt.overrideMimeType = `text/html; charset=${cset}`;
  472. message2(LOC.t1, -1);
  473. loadingStyle('add', c.articleContainer);
  474. gmRequest();
  475. } else {
  476. state = null;
  477. if (st.cantdisplay === 0) {
  478. var eb = $id(`embed_button_${c.item.id}`);
  479. if (eb && eb.classList.contains('article_title_buttons_active')) message();
  480. else message2(LOC.t88);
  481. contentScriptInjection(`embed_article("${c.item.id}","${opt.url}");`);
  482. } else if (st.cantdisplay === 1) {
  483. var mb = $id(`mobilize_button_${c.item.id}`);
  484. if (mb && mb.classList.contains('article_title_buttons_active')) message();
  485. else message2(LOC.t74);
  486. contentScriptInjection(`mobilize("${c.item.id}");`);
  487. } else if (st.cantdisplay === 2) {
  488. message2(LOC.t10);
  489. loadingStyle('open', c.articleContainer);
  490. GM_openInTab(opt.url, true);
  491. window.setTimeout(() => loadingStyle('remove', c.articleContainer), 1000);
  492. } else {
  493. message2(LOC.t86);
  494. }
  495. }
  496. }
  497. } else {
  498. state = null;
  499. var stat = (res.status) ? ` : ${res.status}` : '';
  500. self.requestError.apply(self, [`Request Error${stat}`]);
  501. }
  502. }
  503. };
  504. if (opt.method === 'HEAD') message2(LOC.t54, -1);
  505. else if (opt.method === 'GET') {
  506. message2(LOC.t0, -1);
  507. loadingStyle('add', c.articleContainer);
  508. }
  509. if (opt.url.indexOf('http:') !== 0 && this.info.base) opt.url = pathToURL(this.info.base, opt.url);
  510. gmRequest();
  511. };
  512.  
  513. FullFeed.prototype.requestLoad = function(res, c) {
  514. state = 'loading';
  515. var text = res.responseText,
  516. html = createHTMLDocumentByString(text),
  517. tmpElm = (this.info.xpath) ? getElementsByXPath(this.info.xpath, html) : null;
  518. if (tmpElm) {
  519. var tmpNode = document.createDocumentFragment().appendChild(document.createElement('div')),
  520. doc;
  521. try {
  522. doc = document.cloneNode(false);
  523. doc.appendChild(doc.importNode(document.documentElement, false));
  524. } catch (e) {
  525. doc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
  526. }
  527. try {
  528. tmpNode = doc.adoptNode(tmpNode);
  529. } catch (e) {
  530. tmpNode = doc.importNode(tmpNode, true);
  531. }
  532. tmpElm.forEach(elm => tmpNode.appendChild(elm));
  533. if (tmpNode.innerHTML) text = tmpNode.innerHTML;
  534. }
  535. ['head', 'isindex', 'link', 'script', 'style', 'title'].forEach(t => {
  536. var r = new RegExp(`<(?:!--\\s*)?${t}(?:\\s[^>]+?)?>[\\S\\s]*?<\\/${t}\\s*>`, 'gi');
  537. text = text.replace(r, '');
  538. });
  539. var re = /(<[^>]+?[\s"'])(?:on(?:(?:un)?load|(?:dbl)?click|mouse(?:down|up|over|move|out)|key(?:press|down|up)|focus|blur|submit|reset|select|change|error)|submit|target|usemap|formaction)\s*=\s*(?:"(?:\\"|[^"])*"?|'(\\'|[^'])*'?|[^\s>]+(?=[\s>]|<\w))(?=[^>]*?>|<\w|\s*$)/gi;
  540. while (re.test(text)) {
  541. text = text.replace(re, '$1');
  542. }
  543. if (st.noscripttag) text = text.replace(/<noscript(?:\s[^>]+?)?>([\S\s]*?)<\/noscript\s*>/gi, '<div>$1</div>');
  544. else text = text.replace(/<noscript(?:\s[^>]+?)?>([\S\s]*?)<\/noscript\s*>/gi, '');
  545. var htmldoc = createHTMLDocumentByString(text);
  546. if (st.iframetag) {
  547. var iframe = htmldoc.getElementsByTagName('iframe');
  548. for (var i = 0, j = iframe.length; i < j; i++) {
  549. if (iframe[i] && (!st.allowiframeurl || (iframe[i].src && !new RegExp(st.allowiframeurl).test(iframe[i].src)))) iframe[i].parentNode.removeChild(iframe[i]);
  550. }
  551. }
  552. removeXSSRisks(htmldoc);
  553. if (res.finalUrl) this.requestURL = res.finalUrl;
  554. if (st.lazyloadurl && new RegExp(st.lazyloadurl, 'i').test(c.item.url)) replaceSrcOriginal(htmldoc);
  555. relativeToAbsolutePath(htmldoc, this.requestURL);
  556. var self = this,
  557. entry;
  558. FullFeed.documentFilters.forEach(filter => filter(htmldoc, self.requestURL, self.info));
  559. try {
  560. entry = getElementsByXPath('//html/child::node()', htmldoc);
  561. } catch (er1) {
  562. message(er1, 5000, 'warning');
  563. return;
  564. }
  565. if (!tmpElm) {
  566. if (st.autosearch) {
  567. if (debugLog) console.log('Auto Search');
  568. message(LOC.t1, -1);
  569. entry = searchEntry(htmldoc);
  570. } else {
  571. state = null;
  572. GM_openInTab(self.requestURL, true);
  573. window.setTimeout(() => loadingStyle('remove', c.articleContainer), 1000);
  574. return message(LOC.t10, 2000);
  575. }
  576. }
  577. if (entry) {
  578. if (c.innerContents && !c.innerContents.classList.contains('irff_loaded')) this.removeEntry();
  579. entry = this.addEntry(entry, c);
  580. if (!tmpElm && st.autosearch) this.requestEnd(c, true);
  581. else this.requestEnd(c);
  582. } else {
  583. state = null;
  584. message(LOC.t3);
  585. contentScriptInjection(`mobilize(${c.item.id});`);
  586. }
  587. };
  588.  
  589. FullFeed.prototype.requestEnd = function(c, as, halt) {
  590. state = 'loaded';
  591. xhr.length = 0;
  592. window.setTimeout(() => state = 'wait', 1000);
  593. loadingStyle('remove', c.articleContainer);
  594. c.innerContents.classList.add(this.info.enc || document.characterSet);
  595. c.innerContents.classList.remove('entry-body-empty');
  596. c.innerContents.classList.add('irff_loaded');
  597. c.innerContents.classList.toggle(this.requestURL);
  598. var el = document.querySelector(`${currentEntry()} .irff_checked_icon`);
  599. FullFeed.checkNextPage(c.innerContents);
  600. if (c.innerContents.className.split(/\s+/).filter(i => /^http/.test(i)).length > 1) {
  601. if (nextPageLink) {
  602. if (as) message(LOC.t34, 3000);
  603. else message(LOC.t5);
  604. } else {
  605. if (as) message(LOC.t35, 3000);
  606. else message(LOC.t6);
  607. if (el) {
  608. el.classList.remove('irff_checked_icon_next');
  609. el.classList.remove('irff_checked_icon_as_next');
  610. if (as) el.classList.add('irff_checked_icon_as_nonext');
  611. else el.classList.add('irff_checked_icon_nonext');
  612. el.title = `Ctrl+${LOC.t40} : ${LOC.t39}`;
  613. }
  614. }
  615. } else {
  616. if (as) message(LOC.t51, 3000);
  617. else message(LOC.t2);
  618. if (el) {
  619. el.classList.remove('irff_checked_icon_info');
  620. el.classList.remove('irff_checked_icon_noinfo');
  621. if (nextPageLink) {
  622. if (as) el.classList.add('irff_checked_icon_as_next');
  623. else el.classList.add('irff_checked_icon_next');
  624. el.title = `${LOC.t40} : ${LOC.t41} / Ctrl+${LOC.t40} : ${LOC.t39}`;
  625. if (st.autopagerize) {
  626. window.setTimeout(() => FullFeed.checkScroll(), 2000);
  627. }
  628. } else {
  629. if (as) el.classList.add('irff_checked_icon_as_nonext');
  630. else el.classList.add('irff_checked_icon_nonext');
  631. el.title = `Ctrl+${LOC.t40} : ${LOC.t39}`;
  632. }
  633. }
  634. }
  635. if (halt) message(LOC.t61, 3000);
  636. if (st.embeddedtweets && twttr) twttr.widgets.load(c.innerContents);
  637. for (var p in this) {
  638. if (Object.prototype.hasOwnProperty.call(this, p)) this[p] = void 0;
  639. }
  640. };
  641.  
  642. FullFeed.checkScroll = function() {
  643. if (!nextPageLink || (state && !/^loaded$|^wait$/.test(state))) return;
  644. window.clearTimeout(scrollInterval);
  645. scrollInterval = window.setTimeout(() => {
  646. var s = 'reader_pane_view_style_',
  647. e1 = $id('reader_pane'),
  648. e2 = document.querySelector(currentEntry()),
  649. btn = $id('view_style_img'),
  650. remain;
  651. if (!e1 || !e2 || ((e1.classList.contains(`${s}0`) || (btn && btn.hasAttribute('src') && /menu2\.png$/.test(btn.getAttribute('src')))) && !e2.classList.contains('article_expanded'))) return;
  652. if (e1.classList.contains(`${s}2`)) {
  653. e1 = $id('three_way_contents');
  654. remain = nextPageLink.offsetTop - nextPageLink.offsetHeight - e1.offsetHeight - e1.scrollTop;
  655. } else if (e1.classList.contains(`${s}3`) || e1.classList.contains(`${s}4`)) {
  656. remain = nextPageLink.offsetTop - nextPageLink.offsetHeight - $id('article_dialog_wrapper').offsetHeight - $id('article_dialog').scrollTop;
  657. } else {
  658. remain = e2.offsetTop + nextPageLink.offsetTop - nextPageLink.offsetHeight - e1.offsetHeight - e1.scrollTop;
  659. }
  660. if (remain < st.apheight) {
  661. nextPageLink = null;
  662. initFullFeed();
  663. }
  664. }, 100);
  665. };
  666.  
  667. FullFeed.checkNextPage = function(con) {
  668. var con2 = con.cloneNode(true),
  669. aClass = con.className.split(/\s+/),
  670. finalUrl = aClass[aClass.length - 1],
  671. c = new GetCurrentItem(),
  672. bMatch;
  673. var check = function(data, flag) {
  674. var nextEl, nextEl2;
  675. if (data.some(info => {
  676. if (info.url && info.url.length <= 12 && !/^\^?https?/i.test(info.url)) {
  677. if (new RegExp('^://', 'i').test(info.url)) info.url = `^https?${info.url}`;
  678. else if (new RegExp('^//', 'i').test(info.url)) info.url = `^https?:${info.url}`;
  679. else info.url = `^https?://${info.url}`;
  680. }
  681. if (!bMatch && new RegExp(info.url).test(finalUrl) && info.url.length > 12) {
  682. var nextLink = info.nextLink,
  683. elms, elms2, bCache, bList;
  684. if (nextLink) nextLink = nextLink.replace(/id\(([^)]+)\)/g, '//*[@id=$1]');
  685. if (nextLink) {
  686. elms2 = getElementsByXPath(nextLink, con2);
  687. elms = getElementsByXPath(nextLink, con);
  688. }
  689. if (!elms2) elms2 = getElementsByXPath('//a[@rel="next"]', con2);
  690. if (!elms) elms = getElementsByXPath('//a[@rel="next"]', con);
  691. if (elms2 && elms2.length > 0) nextEl2 = elms2[elms2.length - 1];
  692. if (elms && elms.length > 0 && nextEl2 && nextEl2.href) {
  693. var arr = [];
  694. for (var i = 0, j = elms.length; i < j; i++) {
  695. if (nextEl2.href === elms[i].href) arr.push(elms[i]);
  696. }
  697. nextEl = (arr.length) ? arr[arr.length - 1] : elms[elms.length - 1];
  698. }
  699. if (nextEl2 && finalUrl !== nextEl2.href) {
  700. if (flag === 'cache') {
  701. if (userCacheListAP.some(u => {
  702. if (u === c.feed.url) return true;
  703. })) {
  704. userCacheAP.some(u => {
  705. if (u === info) {
  706. bMatch = true;
  707. return true;
  708. }
  709. });
  710. }
  711. } else bMatch = true;
  712. if (flag === 'full') {
  713. if (userCacheListAP.some(u => {
  714. if (u === c.feed.url) {
  715. bList = true;
  716. return true;
  717. }
  718. })) {
  719. userCacheAP.some(u => {
  720. if (u === info) {
  721. bCache = true;
  722. return true;
  723. }
  724. });
  725. }
  726. if (!bCache) {
  727. delete info.exampleUrl;
  728. delete info.insertBefore;
  729. userCacheAP.push(info);
  730. try {
  731. localStorage.setItem('InoReaderFullFeed_userCacheAP', JSON.stringify(userCacheAP));
  732. if (!bList) {
  733. userCacheListAP.push(c.feed.url);
  734. localStorage.setItem('InoReaderFullFeed_userCacheListAP', JSON.stringify(userCacheListAP));
  735. }
  736. } catch (er) { console.error(er); }
  737. }
  738. }
  739. return true;
  740. }
  741. return false;
  742. }
  743. return false;
  744. })) nextPageLink = (nextEl) ? nextEl : null;
  745. };
  746. check(userSiteInfoAP, 'set');
  747. if (!bMatch) check(userCacheAP, 'cache');
  748. if (!bMatch) {
  749. siteInfoAP.some(ctx => {
  750. if (cacheAPInfo[ctx.url]) {
  751. check(cacheAPInfo[ctx.url].info, 'full');
  752. if (bMatch) return true;
  753. }
  754. });
  755. }
  756. if (bMatch && nextPageLink && st.denynexturl) {
  757. var re = new RegExp(st.denynexturl, 'i');
  758. if (re.test(nextPageLink.href)) nextPageLink = null;
  759. }
  760. };
  761.  
  762. FullFeed.prototype.requestError = function(e) {
  763. state = null;
  764. message(`Error: ${e}`, 5000, 'warning');
  765. loadingStyle('remove', this.itemInfo.articleContainer);
  766. this.itemInfo.innerContents.classList.add('irff_error');
  767. };
  768.  
  769. FullFeed.prototype.removeEntry = function() {
  770. if (this.itemInfo && this.itemInfo.itemBody) {
  771. while (this.itemInfo.itemBody.firstChild) {
  772. this.itemInfo.itemBody.removeChild(this.itemInfo.itemBody.firstChild);
  773. }
  774. }
  775. };
  776.  
  777. FullFeed.prototype.addEntry = function(entry, c) {
  778. var url = this.requestURL || c.itemURL,
  779. ic = (c.innerContents.id) ? $id(c.innerContents.id) : c.innerContents,
  780. div = document.createElement('div');
  781. if (ic && ic.hasChildNodes()) {
  782. div.className = 'irff_pager';
  783. var http = c.innerContents.className.split(/\s+/).filter(i => /^http/.test(i));
  784. var host = (readingPageUrl.split('/')[2] !== url.split('/')[2]) ? `<span class="irff_pager_differenthost">( ${readingPageUrl.split('/')[2]} &rarr; ${url.split('/')[2]} )</span>` : '';
  785. div.innerHTML = `<hr />page: <a href="${url}" target="_blank">${ http.length + 1 }</a>${host}`;
  786. ic.appendChild(div);
  787. } else {
  788. div.className = 'irff_entry_url';
  789. div.innerHTML = `<a href="${url}" class="bluelink" target="_blank">${url}</a>`;
  790. try {
  791. if (ic) ic.parentNode.insertBefore(div, ic);
  792. } catch (er) {
  793. message(`Error: ${er}`, 5000, 'warning');
  794. }
  795. }
  796. return entry.map(i => {
  797. var pe = document.importNode(i, true);
  798. if (ic) ic.appendChild(pe);
  799. return pe;
  800. });
  801. };
  802.  
  803. FullFeed.resetCache = function() {
  804. message(LOC.t11, -1);
  805. var getSiteinfo = function(data, flag) {
  806. var nCache = 0,
  807. nCaches = (flag) ? siteInfo.length : siteInfoAP.length;
  808. data.forEach(ctx => {
  809. var opt = {
  810. method: 'get',
  811. url: ctx.url,
  812. ignoreCache: true,
  813. onload: function(res) {
  814. nCache += 1;
  815. if (res.status === 200) {
  816. if (flag) {
  817. FullFeed.setCache(res, ctx, 'cache');
  818. if (nCache === nCaches) getSiteinfo(siteInfoAP);
  819. } else {
  820. if (nCache === nCaches) FullFeed.setCache(res, ctx, 'cacheAP', true);
  821. else FullFeed.setCache(res, ctx, 'cacheAP');
  822. }
  823. } else if (flag && nCache === nCaches) getSiteinfo(siteInfoAP);
  824. },
  825. onerror: function() {
  826. nCache += 1;
  827. if (flag && nCache === nCaches) getSiteinfo(siteInfoAP);
  828. }
  829. };
  830. GM_xmlhttpRequest(opt);
  831. });
  832. };
  833. getSiteinfo(siteInfo, true);
  834. };
  835.  
  836. FullFeed.removeCache = function() {
  837. if (window.confirm(LOC.t16)) {
  838. localStorage.removeItem('InoReaderFullFeed_cache');
  839. localStorage.removeItem('InoReaderFullFeed_cacheAP');
  840. localStorage.removeItem('InoReaderFullFeed_userCache');
  841. localStorage.removeItem('InoReaderFullFeed_userCacheAP');
  842. localStorage.removeItem('InoReaderFullFeed_userCacheList');
  843. localStorage.removeItem('InoReaderFullFeed_userCacheListAP');
  844. cacheInfo = {};
  845. cacheAPInfo = {};
  846. userCache.length = 0;
  847. userCacheAP.length = 0;
  848. userCacheList.length = 0;
  849. userCacheListAP.length = 0;
  850. }
  851. };
  852.  
  853. FullFeed.setCache = function(res, ctx, item, flag) {
  854. var info = [];
  855. var setJson = function(t) {
  856. try {
  857. info = JSON.parse(t)
  858. .sort((a, b) => {
  859. a = new Date(a.updated_at).getTime();
  860. b = new Date(b.updated_at).getTime();
  861. if (!isNaN(a) && !isNaN(b)) return new Date(b).getTime() - new Date(a).getTime();
  862. return b;
  863. })
  864. .map(i => i.data);
  865. } catch (er1) { console.error(er1); }
  866. };
  867. switch (ctx.format.toUpperCase()) {
  868. case 'JSON':
  869. setJson(res.responseText);
  870. break;
  871. case 'JSONP':
  872. if (ctx.callback) {
  873. try {
  874. var txt = res.responseText;
  875. txt = txt.replace(new RegExp(`${ctx.callback}\\s*\\(\\s*\\[\\s*\\{`, 'gm'), `${ctx.callback}([{`).replace(/\}\s*\]\s*\)/gm, '}])');
  876. txt = txt.slice(txt.indexOf(`${ctx.callback}([{`) + ctx.callback.length + 1);
  877. txt = txt.slice(0, txt.lastIndexOf('}])') + 2);
  878. setJson(txt);
  879. } catch (er2) { console.error(er2); }
  880. } else message(LOC.t17, 5000, 'warning');
  881. break;
  882. }
  883. if (info.length > 0) {
  884. if (item === 'cache') {
  885. cacheInfo[ctx.url] = {
  886. url: ctx.url,
  887. info: info
  888. };
  889. try {
  890. localStorage.setItem('InoReaderFullFeed_cache', JSON.stringify(cacheInfo));
  891. } catch (er3) {
  892. if (er3 && er3.name && er3.message) window.alert(`${er3.name}\n${er3.message}`);
  893. }
  894. localStorage.removeItem('InoReaderFullFeed_userCache');
  895. localStorage.removeItem('InoReaderFullFeed_userCacheList');
  896. userCache.length = 0;
  897. userCacheList.length = 0;
  898. } else if (item === 'cacheAP') {
  899. cacheAPInfo[ctx.url] = {
  900. url: ctx.url,
  901. info: info
  902. };
  903. try {
  904. localStorage.setItem('InoReaderFullFeed_cacheAP', JSON.stringify(cacheAPInfo));
  905. } catch (er4) {
  906. if (er4 && er4.name && er4.message) window.alert(`${er4.name}\n${er4.message}`);
  907. }
  908. localStorage.removeItem('InoReaderFullFeed_userCacheAP');
  909. localStorage.removeItem('InoReaderFullFeed_userCacheListAP');
  910. userCacheAP.length = 0;
  911. userCacheListAP.length = 0;
  912. }
  913. if (flag) {
  914. var hasFF = (localStorage.getItem('InoReaderFullFeed_cache')) ? true : false,
  915. hasAP = (localStorage.getItem('InoReaderFullFeed_cacheAP')) ? true : false;
  916. if (hasFF && hasAP) message(LOC.t12, 5000);
  917. else message(LOC.t14, 5000, 'warning');
  918. }
  919. }
  920. };
  921.  
  922. FullFeed.getCache = function(key) {
  923. var js = '{}';
  924. if (localStorage.getItem(`InoReaderFullFeed_${key}`)) js = localStorage.getItem(`InoReaderFullFeed_${key}`);
  925. else if (/^cache.+/.test(key)) FullFeed.resetCache();
  926. else if (/^user.+/.test(key)) js = '[]';
  927. try {
  928. return JSON.parse(js);
  929. } catch (er) {
  930. if (/^user.+/.test(key)) return [];
  931. return {};
  932. }
  933. };
  934.  
  935. FullFeed.saveSettings = function() {
  936. delete st.sociallivedoor;
  937. delete st.socialfc2;
  938. try {
  939. localStorage.setItem('InoReaderFullFeed_settings', JSON.stringify(st));
  940. } catch (er) {
  941. window.alert('Error: Save Settings');
  942. }
  943. };
  944.  
  945. FullFeed.loadSettings = function(data) {
  946. if (data === 'reset') st = {};
  947. else if (data) st = data;
  948. else {
  949. st = {};
  950. try {
  951. if (localStorage.getItem('InoReaderFullFeed_settings')) st = JSON.parse(localStorage.getItem('InoReaderFullFeed_settings'));
  952. } catch (er1) { console.error(er1); }
  953. }
  954. var notType = function(t, a) {
  955. return (Object.prototype.toString.call(a).slice(8, 11) !== t) ? true : false;
  956. };
  957. if (notType('Str', st.allowiframeurl)) st.allowiframeurl = '';
  958. if (notType('Str', st.allownexturl)) st.allownexturl = '';
  959. if (notType('Num', st.apheight) || st.apheight < 200 || st.apheight > 2000) st.apheight = 500;
  960. if (notType('Num', st.autoload) || st.autoload < 0 || st.autoload > 3) st.autoload = 2;
  961. if (notType('Arr', st.autoloadarticle)) st.autoloadarticle = [];
  962. if (notType('Arr', st.autoloadfeed)) st.autoloadfeed = [];
  963. if (notType('Boo', st.autopagerize)) st.autopagerize = true;
  964. if (notType('Boo', st.autosearch)) st.autosearch = true;
  965. if (isFinite(st.basekey)) st.basekey = +st.basekey;
  966. else if (!notType('Str', st.basekey) && st.basekey.length === 1) st.basekey = st.basekey.toUpperCase();
  967. else st.basekey = 'Z';
  968. if (notType('Num', st.cantdisplay) || st.cantdisplay < 0 || st.cantdisplay > 3) st.cantdisplay = 0;
  969. if (!st.version) st.cantdisplay += 1;
  970. if (notType('Str', st.denynexturl)) st.denynexturl = '';
  971. if (notType('Arr', st.disableitem)) st.disableitem = [];
  972. if (notType('Boo', st.embeddedtweets)) st.embeddedtweets = true;
  973. if (notType('Boo', st.iframetag)) st.iframetag = true;
  974. if (notType('Str', st.lazyloadurl)) st.lazyloadurl = '';
  975. if (notType('Str', st.lazyloadattr)) st.lazyloadattr = '"ajax","data-lazy-src","data-original","data-src"';
  976. if (notType('Str', st.mode)) st.mode = 'simple';
  977. if (notType('Boo', st.noscripttag)) st.noscripttag = true;
  978. if (notType('Arr', st.notloadarticle)) st.notloadarticle = [];
  979. if (notType('Arr', st.notloadfeed)) st.notloadfeed = [];
  980. if (notType('Str', st.notread)) st.notread = '';
  981. if (notType('Boo', st.openitem)) st.openitem = false;
  982. if (notType('Str', st.replacefullfeedurl)) st.replacefullfeedurl = '';
  983. if (notType('Boo', st.socialbuzzurl)) st.socialbuzzurl = false;
  984. if (notType('Boo', st.socialicon)) st.socialicon = true;
  985. if (notType('Boo', st.socialdelicious)) st.socialdelicious = false;
  986. if (notType('Boo', st.socialfacebook)) st.socialfacebook = false;
  987. if (notType('Boo', st.socialgoogleplus)) st.socialgoogleplus = false;
  988. if (notType('Boo', st.socialhatena)) st.socialhatena = false;
  989. if (notType('Boo', st.socialtwitter)) st.socialtwitter = true;
  990. if (notType('Boo', st.socialyahoo)) st.socialyahoo = false;
  991. if (notType('Num', st.timeout) || st.timeout < 10 || st.timeout > 99) st.timeout = 15;
  992. try {
  993. siteInfo = JSON.parse(st.siteinfo);
  994. } catch (er2) {
  995. siteInfo = [{
  996. 'format': 'JSON',
  997. 'url': 'http://wedata.net/databases/LDRFullFeed/items.json'
  998. }];
  999. st.siteinfo = JSON.stringify(siteInfo);
  1000. }
  1001. try {
  1002. siteInfoAP = JSON.parse(st.siteinfoap);
  1003. } catch (er3) {
  1004. siteInfoAP = [{
  1005. 'format': 'JSON',
  1006. 'url': 'http://wedata.net/databases/AutoPagerize/items.json'
  1007. }];
  1008. st.siteinfoap = JSON.stringify(siteInfoAP);
  1009. }
  1010. try {
  1011. userSiteInfo = JSON.parse(st.usersiteinfo);
  1012. } catch (er4) {
  1013. userSiteInfo = [{
  1014. 'url': '',
  1015. 'xpath': '',
  1016. 'type': '',
  1017. 'enc': ''
  1018. }];
  1019. st.usersiteinfo = JSON.stringify(userSiteInfo);
  1020. }
  1021. try {
  1022. userSiteInfoAP = JSON.parse(st.usersiteinfoap);
  1023. } catch (er5) {
  1024. userSiteInfoAP = [{
  1025. 'url': '',
  1026. 'nextLink': '',
  1027. 'pageElement': ''
  1028. }];
  1029. st.usersiteinfoap = JSON.stringify(userSiteInfoAP);
  1030. }
  1031. };
  1032.  
  1033. FullFeed.createSettings = function() {
  1034. var div = document.createElement('div');
  1035. div.id = 'irff_s';
  1036. div.style.display = 'none';
  1037. div.innerHTML = `<div id="irff_s-titlebar"><div id="irff_s-titlebar_title"><a href="https://greasyfork.org/scripts/897-inoreader-full-feed" target="_blank">InoReader Full Feed ${LOC.t21}</a></div><div id="irff_s-titlebar_button"><input type="button" id="irff_s-ok" value="OK"><input type="button" id="irff_s-cancel" value="${LOC.t22}"></div></div><div id="irff_s-tab"></div><ul id="irff_s-list"></ul>`;
  1038. document.body.appendChild(div);
  1039. var list = [{
  1040. tab: 'General',
  1041. id: 'general',
  1042. body: `<fieldset><legend>${LOC.t23}</legend><label>${LOC.t18} : <input type="text" id="irff_s-general_key"><span id="irff_s-general_keydesc"></span></label><a href="javascript:void(0);" id="irff_s-general_keyhelpicon">[ ? ]</a><div id="irff_s-general_keyhelpbody">${LOC.t26} : Ctrl+ (${LOC.t18}) ${LOC.t24}<br>${LOC.t27} : Shift+ (${LOC.t18}) ${LOC.t24}<br>${LOC.t28} : Ctrl+Shift+ (${LOC.t18}) ${LOC.t24}<br>${LOC.t29} : Alt+Ctrl+Shift+ (${LOC.t18}) ${LOC.t24}</div></fieldset><fieldset><legend>${LOC.t18}</legend><label><input type="checkbox" id="irff_s-general_ap">${LOC.t41}</label><label class="irff_s-advance"> ( <input type="number" min="200" max="2000" id="irff_s-general_apheight">px )</label><br><label><input type="checkbox" id="irff_s-general_autosearch">${LOC.t64}</label><br><label><input type="checkbox" id="irff_s-general_embeddedtweets">${LOC.t89}</label><br><label>${LOC.t75} : <select id="irff_s-general_cantdisplay"><option>${LOC.t87}</option><option>${LOC.t83}</option><option>${LOC.t84}</option><option>${LOC.t85}</option></select></label><fieldset class="irff_s-advance"><legend>${LOC.t47} (${LOC.t19}) : </legend><input type="text" id="irff_s-general_notread"><br><label><input type="checkbox" id="irff_s-general_openitem">${LOC.t48}</label></fieldset></fieldset>`
  1043. }, {
  1044. tab: 'Site Info',
  1045. id: 'siteinfo',
  1046. body: `<div id="irff_s-siteinfo_navi" class="irff_s-navi"><span id="irff_s-siteinfo_navi_ff" class="irff_s-siteinfo_navi irff_s-advance">FF URL</span><span id="irff_s-siteinfo_navi_ap" class="irff_s-siteinfo_navi irff_s-advance">AP URL</span><span id="irff_s-siteinfo_navi_uff" class="irff_s-siteinfo_navi select">FF SITEINFO</span><span id="irff_s-siteinfo_navi_uap" class="irff_s-siteinfo_navi">AP SITEINFO</span><span id="irff_s-siteinfo_navi_disableitem" class="irff_s-siteinfo_navi irff_s-advance">disable Item</span></div><fieldset id="irff_s-siteinfo_f_ff" class="irff_s-advance"><legend>${LOC.t30}</legend><textarea id="irff_s-siteinfo_ff"></textarea></fieldset><fieldset id="irff_s-siteinfo_f_ap" class="irff_s-advance"><legend>${LOC.t31}</legend><textarea id="irff_s-siteinfo_ap"></textarea></fieldset><fieldset id="irff_s-siteinfo_f_uff" class="select"><legend>${LOC.t32}</legend><div class="irff_s-siteinfo_form"><div><label class="irff_s-siteinfo_user_label irff_s-table"><span>url:</span><input type="text" id="irff_s-siteinfo_uff_url" class="irff_s-siteinfo_text"></label></div><div><label class="irff_s-siteinfo_user_label irff_s-table"><span>xpath:</span><input type="text" id="irff_s-siteinfo_uff_xpath" class="irff_s-siteinfo_text"></label></div><div class="irff_s-table"><label id="irff_s-siteinfo_uff_type_label" class="irff_s-siteinfo_user_label"><span>type:</span><select id="irff_s-siteinfo_uff_type"><option value="IND">INDIVIDUAL</option><option value="SUB">SUBGENERAL</option><option value="GEN">GENERAL</option></select></label><label id="irff_s-siteinfo_user_label_enc"><div class="irff_s-table"><span id="irff_s-siteinfo_uff_enc_span">enc:</span><input type="text" id="irff_s-siteinfo_uff_enc" class="irff_s-siteinfo_text" list="irff_s-siteinfo_enc"></div></label><datalist id="irff_s-siteinfo_enc"><option value="UTF-8"><option value="EUC-JP"><option value="Shift_JIS"></datalist><span class="irff_s-addbutton_span"><input type="button" id="irff_s-siteinfo_uff_add" class="irff_s-addbutton" value="${LOC.t20}"></span></div></div><textarea id="irff_s-siteinfo_uff"></textarea></fieldset><fieldset id="irff_s-siteinfo_f_uap"><legend>${LOC.t33}</legend><div class="irff_s-siteinfo_form"><div><label class="irff_s-siteinfo_user_label irff_s-table"><span>url:</span><input type="text" id="irff_s-siteinfo_uap_url" class="irff_s-siteinfo_text"></label></div><div><label class="irff_s-siteinfo_user_label irff_s-table"><span>nextLink:</span><input type="text" id="irff_s-siteinfo_uap_nextlink" class="irff_s-siteinfo_text"></label></div><div class="irff_s-table"><label id="irff_s-siteinfo_uap_pageelement_label" class="irff_s-siteinfo_user_label"><div class="irff_s-table"><span id="irff_s-siteinfo_uap_pageelement_span">pageElement:</span><input type="text" id="irff_s-siteinfo_uap_pageelement" class="irff_s-siteinfo_text"></div></label><span class="irff_s-addbutton_span"><input type="button" id="irff_s-siteinfo_uap_add" class="irff_s-addbutton" value="${LOC.t20}"></span></div></div><textarea id="irff_s-siteinfo_uap"></textarea></fieldset><fieldset id="irff_s-siteinfo_f_disableitem" class="irff_s-advance"><legend>disable SITEINFO Item</legend><div id="irff_s-siteinfo_disableitemlist"></div><textarea id="irff_s-siteinfo_disableitem"></textarea></fieldset>`
  1047. }, {
  1048. tab: 'Auto Load',
  1049. id: 'autoload',
  1050. body: `<div id="irff_s-autoload_navi" class="irff_s-navi"><span id="irff_s-autoload_navi_whitelist" class="irff_s-autoload_navi select">${LOC.t44}</span><span id="irff_s-autoload_navi_blacklist" class="irff_s-autoload_navi">${LOC.t76}</span></div><fieldset id="irff_s-autoload_f_whitelist" class="select"><legend>${LOC.t44} (${LOC.t19})</legend><label class="irff_s-r"><input type="radio" name="irff_s-autoload_whitelist_r" value="wf" id="irff_s-autoload_whitelist_r_feed">${LOC.t37}</label><label class="irff_s-r"><input type="radio" name="irff_s-autoload_whitelist_r" value="wa" id="irff_s-autoload_whitelist_r_article">${LOC.t38}</label><div id="irff_s-autoload_whitelist_feed" class="irff_s-autoload_form select"><div class="irff_s-table"><input type="text" id="irff_s-autoload_whitelist_feed_title" class="irff_s-autoload_title"><span class="irff_s-addbutton_span"><input type="button" id="irff_s-autoload_whitelist_feed_add" class="irff_s-addbutton" value="${LOC.t20}"></span></div><textarea id="irff_s-autoload_whitelist_feed_list" class="irff_s-autoload_list"></textarea></div><div id="irff_s-autoload_whitelist_article" class="irff_s-autoload_form"><div class="irff_s-table"><input type="text" id="irff_s-autoload_whitelist_article_title" class="irff_s-autoload_title"><span class="irff_s-addbutton_span"><input type="button" id="irff_s-autoload_whitelist_article_add" class="irff_s-addbutton" value="${LOC.t20}"></span></div><textarea id="irff_s-autoload_whitelist_article_list" class="irff_s-autoload_list"></textarea></div></fieldset><fieldset id="irff_s-autoload_f_blacklist"><legend>${LOC.t76} (${LOC.t19})</legend><label class="irff_s-r"><input type="radio" name="irff_s-autoload_blacklist_r" value="bf" id="irff_s-autoload_blacklist_r_feed">${LOC.t37}</label><label class="irff_s-r"><input type="radio" name="irff_s-autoload_blacklist_r" value="ba" id="irff_s-autoload_blacklist_r_article">${LOC.t38}</label><div id="irff_s-autoload_blacklist_feed" class="irff_s-autoload_form select"><div class="irff_s-table"><input type="text" id="irff_s-autoload_blacklist_feed_title" class="irff_s-autoload_title"><span class="irff_s-addbutton_span"><input type="button" id="irff_s-autoload_blacklist_feed_add" class="irff_s-addbutton" value="${LOC.t20}"></span></div><textarea id="irff_s-autoload_blacklist_feed_list" class="irff_s-autoload_list"></textarea></div><div id="irff_s-autoload_blacklist_article" class="irff_s-autoload_form"><div class="irff_s-table"><input type="text" id="irff_s-autoload_blacklist_article_title" class="irff_s-autoload_title"><span class="irff_s-addbutton_span"><input type="button" id="irff_s-autoload_blacklist_article_add" class="irff_s-addbutton" value="${LOC.t20}"></span></div><textarea id="irff_s-autoload_blacklist_article_list" class="irff_s-autoload_list"></textarea></div></fieldset><div><label>${LOC.t43} : <select id="irff_s-autoload_mode"><option>${LOC.t36}</option><option>${LOC.t77}</option><option>${LOC.t45}</option><option>${LOC.t46}</option></select></label></div>`
  1051. }, {
  1052. tab: 'Security',
  1053. id: 'security',
  1054. body: `<label><input type="checkbox" id="irff_s-security_noscripttag">${LOC.t42}</label><br><label><input type="checkbox" id="irff_s-security_iframetag">${LOC.t52}</label><fieldset><legend>${LOC.t65} (${LOC.t19}) : </legend><input type="text" id="irff_s-security_allowiframeurl"></fieldset><fieldset><legend>${LOC.t63} (${LOC.t19}) : </legend><input type="text" id="irff_s-security_denynexturl"></fieldset><fieldset><legend>${LOC.t62} (${LOC.t19}) : </legend><input type="text" id="irff_s-security_allownexturl"></fieldset>`
  1055. }, {
  1056. tab: 'Social',
  1057. id: 'social',
  1058. body: `<fieldset><legend><label><input type="checkbox" id="irff_s-social_socialicon">${LOC.t55}</label></legend><label><input type="checkbox" id="irff_s-social_twitter">Twitter</label><br><label><input type="checkbox" id="irff_s-social_delicious">Delicious</label><br><label><input type="checkbox" id="irff_s-social_facebook">Facebook</label><br><label><input type="checkbox" id="irff_s-social_googleplus">Google+</label><br><label><input type="checkbox" id="irff_s-social_buzzurl">${LOC.t57}</label><br><label><input type="checkbox" id="irff_s-social_yahoo">${LOC.t56}</label><br><label><input type="checkbox" id="irff_s-social_hatena">${LOC.t58}</label></fieldset>`
  1059. }, {
  1060. tab: 'Etc',
  1061. id: 'etc',
  1062. body: `<div class="irff_s-clearfix"><fieldset id="irff_s-etc_mode" class="irff_s-f_column2"><legend>${LOC.t78}</legend><label class="irff_s-r"><input id="irff_s-etc_mode-simple" name="irff_s-etc_mode_r" type="radio" value="simple" />${LOC.t79}</label><label class="irff_s-r"><input id="irff_s-etc_mode-advance" name="irff_s-etc_mode_r" type="radio" value="advance" />${LOC.t80}</label></fieldset><fieldset class="irff_s-f_column2"><legend>Cache Data</legend><input type="button" id="irff_s-etc_cachereset" value="Reset Cache"><input type="button" id="irff_s-etc_cachedelete" class="irff_s-advance" value="Delete Cache"></fieldset></div><div class="irff_s-clearfix"><fieldset class="irff_s-advance irff_s-f_column2"><legend>Timeout</legend><input type="number" min="10" max="99" id="irff_s-etc_timeout">${LOC.t81}</fieldset><fieldset class="irff_s-advance irff_s-f_column2"><legend>Settings Data</legend><input type="button" id="irff_s-etc_settingsimport" value="Import"><input type="button" id="irff_s-etc_settingsexport" value="Export"><input type="button" id="irff_s-etc_settingsreset" value="Reset"></fieldset></div><fieldset class="irff_s-advance"><legend>Replace Full Feed URL : </legend><input type="text" id="irff_s-etc_replacefullfeedurl"></fieldset><fieldset class="irff_s-advance"><legend>Lazy Load URL (${LOC.t19}) : </legend><input type="text" id="irff_s-etc_lazyloadurl"></fieldset><fieldset class="irff_s-advance"><legend>Lazy Load Attribute : </legend><input type="text" id="irff_s-etc_lazyloadattr"></fieldset><label class="irff_s-advance"><input type="checkbox" id="irff_s-etc_debuglog">${LOC.t50}</label>`
  1063. }];
  1064. list.forEach(i => {
  1065. var span = document.createElement('span'),
  1066. div2 = document.createElement('div');
  1067. span.id = `irff_s-tab_${i.id}`;
  1068. span.innerHTML = i.tab;
  1069. div2.id = `irff_s-${i.id}`;
  1070. div2.style.display = 'none';
  1071. div2.innerHTML = i.body;
  1072. if (/security|social/.test(i.id)) {
  1073. span.className = 'irff_s-advance';
  1074. div2.className = 'irff_s-advance';
  1075. }
  1076. $ids('tab').appendChild(span);
  1077. $ids('list').appendChild(div2);
  1078. });
  1079. $ids('autoload_whitelist_r_feed').checked = true;
  1080. $ids('autoload_blacklist_r_feed').checked = true;
  1081. if (st.mode === 'simple') toggleSettingsMode();
  1082. var menu = $id('sb_rp_settings_menu'),
  1083. pqm = $id('preferences_quick_main'),
  1084. item = document.createElement('div');
  1085. item.id = 'irff_s-menu';
  1086. item.innerHTML = `Full Feed ${LOC.t21}`;
  1087. if (menu) {
  1088. item.className = 'inno_toolbar_button_menu_item';
  1089. var menuList = menu.children;
  1090. if (!menuList[menuList.length - 1].id) {
  1091. var line = document.createElement('div');
  1092. line.className = 'inno_toolbar_button_menu_line';
  1093. menu.insertBefore(line, menu.lastChild.nextSibling);
  1094. }
  1095. menu.insertBefore(item, menu.lastChild.nextSibling);
  1096. } else if ($id('quick_options') && pqm) {
  1097. item.className = 'quick_options_link';
  1098. pqm.insertBefore(item, pqm.lastChild.nextSibling);
  1099. }
  1100. $id('irff_s').addEventListener('keydown', e => {
  1101. if (/^input|^textarea/i.test(e.target.tagName)) e.stopPropagation();
  1102. }, false);
  1103. $ids('general_key').addEventListener('keypress', e => e.preventDefault(), false);
  1104. };
  1105.  
  1106. FullFeed.viewSettings = function(id, eIcon) {
  1107. if ($id('irff_s').style.display === 'block') {
  1108. $id('irff_s').style.display = 'none';
  1109. return;
  1110. }
  1111. var tab = $ids('tab').childNodes,
  1112. list = $ids('list').childNodes;
  1113. $ids('general_key').value = st.basekey;
  1114. $ids('general_keydesc').textContent = (isNaN(st.basekey)) ? LOC.t24 : `(${LOC.t25})`;
  1115. $ids('general_ap').checked = (st.autopagerize) ? true : false;
  1116. $ids('general_apheight').value = st.apheight;
  1117. $ids('general_autosearch').checked = (st.autosearch) ? true : false;
  1118. $ids('general_cantdisplay').selectedIndex = st.cantdisplay;
  1119. $ids('general_embeddedtweets').checked = (st.embeddedtweets) ? true : false;
  1120. $ids('general_notread').value = st.notread;
  1121. $ids('general_openitem').checked = (st.openitem) ? true : false;
  1122. var siff = $ids('siteinfo_ff'),
  1123. siap = $ids('siteinfo_ap'),
  1124. siuff = $ids('siteinfo_uff'),
  1125. siuap = $ids('siteinfo_uap'),
  1126. chklist = '';
  1127. var beautifier = function(str) {
  1128. try {
  1129. return JSON.stringify(str).replace(/^\[/g, '[\n').replace(/\{"/g, ' {\n "').replace(/"\}/g, '"\n }').replace(/\},/g, '},\n').replace(/",/g, '",\n ').replace(/\{"/g, '{\n "').replace(/\]$/g, '\n]');
  1130. } catch (er) {
  1131. return '';
  1132. }
  1133. };
  1134. siff.value = beautifier(siteInfo);
  1135. siap.value = beautifier(siteInfoAP);
  1136. siuff.value = beautifier(userSiteInfo);
  1137. siuap.value = beautifier(userSiteInfoAP);
  1138. itemSiteInfo.forEach(a => {
  1139. chklist += `<label title="${a.url}"><input type="checkbox"`;
  1140. if (itemSiteInfo.length === 1) chklist += ' disabled="disabled"';
  1141. else {
  1142. st.disableitem.forEach(b => {
  1143. if (a.url === b) chklist += ' checked';
  1144. });
  1145. }
  1146. chklist += `>${a.url}</label><br>`;
  1147. });
  1148. $ids('siteinfo_disableitemlist').innerHTML = chklist;
  1149. if (st.disableitem) $ids('siteinfo_disableitem').value = st.disableitem.join('\n');
  1150. $ids('autoload_mode').selectedIndex = st.autoload;
  1151. var eCurrent = document.querySelector(currentEntry()),
  1152. feedTitle = '',
  1153. articleTitle = '';
  1154. if (eCurrent && eCurrent.id) {
  1155. var sId, eTitleLink;
  1156. if (eIcon) {
  1157. eTitleLink = eIcon.parentNode.getElementsByClassName('article_title_link')[0];
  1158. if (eTitleLink) sId = eTitleLink.id.slice(eTitleLink.id.lastIndexOf('_') + 1);
  1159. else sId = eCurrent.id.slice(eCurrent.id.lastIndexOf('_') + 1);
  1160. } else sId = eCurrent.id.slice(eCurrent.id.lastIndexOf('_') + 1);
  1161. var eFeed = $id(`article_feed_info_link_${sId}`) ||
  1162. eCurrent.getElementsByClassName('article_feed_title')[0] ||
  1163. eCurrent.querySelector('.article_tile_footer_feed_title > a'),
  1164. eTitle = $id(`at_${sId}`) || eCurrent.getElementsByClassName('article_header_title')[0] ||
  1165. eCurrent.getElementsByClassName('article_title_link')[0];
  1166. if (eFeed) {
  1167. feedTitle = (eFeed.textContent) ? eFeed.textContent : '';
  1168. } else if ($id('tree')) {
  1169. var tlf = $id('tree').getElementsByClassName('selected')[0];
  1170. if (tlf && tlf.textContent) feedTitle = tlf.textContent;
  1171. }
  1172. if (eTitle && eTitle.textContent) articleTitle = eTitle.textContent;
  1173. }
  1174. if (feedTitle) {
  1175. feedTitle = feedTitle.replace(/([*+?.()[\]\\|^$])/g, '\\$1').replace(/^\s*(.*?)/, '$1');
  1176. $ids('autoload_whitelist_feed_title').value = `^${feedTitle}$`;
  1177. $ids('autoload_blacklist_feed_title').value = `^${feedTitle}$`;
  1178. }
  1179. if (articleTitle) {
  1180. $ids('autoload_whitelist_article_title').value = `^${articleTitle}$`;
  1181. $ids('autoload_blacklist_article_title').value = `^${articleTitle}$`;
  1182. }
  1183. if (st.autoloadfeed) $ids('autoload_whitelist_feed_list').value = st.autoloadfeed.join('\n');
  1184. if (st.autoloadarticle) $ids('autoload_whitelist_article_list').value = st.autoloadarticle.join('\n');
  1185. if (st.notloadfeed) $ids('autoload_blacklist_feed_list').value = st.notloadfeed.join('\n');
  1186. if (st.notloadarticle) $ids('autoload_blacklist_article_list').value = st.notloadarticle.join('\n');
  1187. $ids('security_noscripttag').checked = (st.noscripttag) ? true : false;
  1188. $ids('security_iframetag').checked = (st.iframetag) ? true : false;
  1189. $ids('security_allowiframeurl').value = st.allowiframeurl;
  1190. $ids('security_denynexturl').value = st.denynexturl;
  1191. $ids('security_allownexturl').value = st.allownexturl;
  1192. if ($ids('security_iframetag').checked) {
  1193. $ids('security_allowiframeurl').disabled = false;
  1194. $ids('security_allowiframeurl').parentNode.style.color = 'black';
  1195. } else {
  1196. $ids('security_allowiframeurl').disabled = true;
  1197. $ids('security_allowiframeurl').parentNode.style.color = 'gray';
  1198. }
  1199. $ids('social_socialicon').checked = (st.socialicon) ? true : false;
  1200. $ids('social_buzzurl').checked = (st.socialbuzzurl) ? true : false;
  1201. $ids('social_delicious').checked = (st.socialdelicious) ? true : false;
  1202. $ids('social_facebook').checked = (st.socialfacebook) ? true : false;
  1203. $ids('social_googleplus').checked = (st.socialgoogleplus) ? true : false;
  1204. $ids('social_hatena').checked = (st.socialhatena) ? true : false;
  1205. $ids('social_twitter').checked = (st.socialtwitter) ? true : false;
  1206. $ids('social_yahoo').checked = (st.socialyahoo) ? true : false;
  1207. ['buzzurl', 'delicious', 'facebook', 'googleplus', 'hatena', 'twitter', 'yahoo'].forEach(a => {
  1208. if ($ids('social_socialicon').checked) {
  1209. $ids(`social_${a}`).disabled = false;
  1210. $ids(`social_${a}`).parentNode.style.color = 'black';
  1211. } else {
  1212. $ids(`social_${a}`).disabled = true;
  1213. $ids(`social_${a}`).parentNode.style.color = 'gray';
  1214. }
  1215. });
  1216. var bSimple = ($id('irff_s-list').getElementsByClassName('irff_hidden').length) ? true : false;
  1217. if (st.mode === 'simple') {
  1218. $ids('etc_mode-simple').checked = true;
  1219. if (!bSimple) toggleSettingsMode();
  1220. } else if (st.mode === 'advance') {
  1221. $ids('etc_mode-advance').checked = true;
  1222. if (bSimple) toggleSettingsMode();
  1223. }
  1224. $ids('etc_timeout').value = st.timeout;
  1225. $ids('etc_replacefullfeedurl').value = st.replacefullfeedurl;
  1226. $ids('etc_lazyloadurl').value = st.lazyloadurl;
  1227. $ids('etc_lazyloadattr').value = st.lazyloadattr;
  1228.  
  1229. for (var i = 0; i < tab.length; i++) {
  1230. if (tab[i].classList.contains('select')) {
  1231. tab[i].classList.remove('select');
  1232. list[i].style.display = 'none';
  1233. }
  1234. }
  1235. if (id) {
  1236. //※ createSettings()のlistと並び順を合わせること
  1237. var idlist = ['general', 'siteinfo', 'autoload', 'security', 'social', 'etc'];
  1238. idlist.forEach((s, j) => {
  1239. if (id === s) {
  1240. tab[j].classList.add('select');
  1241. list[j].style.display = 'block';
  1242. }
  1243. });
  1244. } else {
  1245. tab[0].classList.add('select');
  1246. list[0].style.display = 'block';
  1247. }
  1248. $id('irff_s').style.display = 'block';
  1249. };
  1250.  
  1251. FullFeed.checkRegister = function() {
  1252. window.setTimeout(() => {
  1253. var currentItem = getActiveItem(true);
  1254. if (currentItem && currentItem.url) {
  1255. FullFeed.registerWidgets(currentItem);
  1256. FullFeed.registerSocialIcons(currentItem);
  1257. }
  1258. }, 10);
  1259. };
  1260.  
  1261. FullFeed.registerWidgets = function() {
  1262. var c = new GetCurrentItem(),
  1263. flag = false,
  1264. el, xhrID;
  1265. if (!c.innerContents) return;
  1266. if (/^https?:\/\/(?:www\.)?inoreader\.com\/?$|^javascript:|\.pdf$/i.test(c.itemURL)) return;
  1267. el = document.querySelectorAll(`${currentEntry()} .article_title > span`);
  1268. for (var i = 0, j = el.length; i < j; i++) {
  1269. if (el[i].classList.contains('irff_checked')) {
  1270. flag = true;
  1271. break;
  1272. }
  1273. }
  1274. if (flag) return;
  1275. var container = document.querySelector(`${currentEntry()} .article_title`),
  1276. description = `${LOC.t40} : ${LOC.t18} / Ctrl+${LOC.t40} : ${LOC.t39}`,
  1277. feed = c.feed,
  1278. title = c.item.title,
  1279. bFound = false;
  1280. if (!container) return;
  1281. itemSiteInfo.length = 0;
  1282. var check = function(b) {
  1283. bFound = true;
  1284. var icon = document.createElement('span');
  1285. icon.title = description;
  1286. icon.innerHTML = 'F';
  1287. icon.classList.add('irff_checked');
  1288. icon.classList.add('irff_checked_icon');
  1289. if (b) icon.classList.add('irff_checked_icon_info');
  1290. else icon.classList.add('irff_checked_icon_noinfo');
  1291. container.appendChild(icon);
  1292. if (st.autoload === 0) initFullFeed();
  1293. else if (st.autoload === 1) {
  1294. if (feed.title && st.notloadfeed.some(k => {
  1295. if (!k) return false;
  1296. if (new RegExp(k, 'i').test(feed.title)) return true;
  1297. })) flag = true;
  1298. else if (title && st.notloadarticle.some(k => {
  1299. if (!k) return false;
  1300. if (new RegExp(k, 'i').test(title)) return true;
  1301. })) flag = true;
  1302. if (!flag) initFullFeed();
  1303. } else if (st.autoload === 2) {
  1304. if (feed.title && st.notloadfeed.some(k => {
  1305. if (!k) return false;
  1306. if (new RegExp(k, 'i').test(feed.title)) return true;
  1307. })) flag = true;
  1308. else if (title && st.notloadarticle.some(k => {
  1309. if (!k) return false;
  1310. if (new RegExp(k, 'i').test(title)) return true;
  1311. })) flag = true;
  1312. if (!flag && feed.title && st.autoloadfeed.some(k => {
  1313. if (!k) return false;
  1314. if (new RegExp(k, 'i').test(feed.title)) return true;
  1315. })) initFullFeed();
  1316. else if (!flag && title && st.autoloadarticle.some(k => {
  1317. if (!k) return false;
  1318. if (new RegExp(k, 'i').test(title)) return true;
  1319. })) initFullFeed();
  1320. }
  1321. };
  1322. userSiteInfo.some(k => {
  1323. try {
  1324. var reg = new RegExp(k.url);
  1325. if (k.url && (reg.test(c.itemURL) || reg.test(feed.url))) {
  1326. check(true);
  1327. return true;
  1328. }
  1329. } catch (er1) {
  1330. console.log('SITEINFO Error: ', k.url);
  1331. }
  1332. });
  1333. if (!bFound) {
  1334. if (userCacheList.some(k => {
  1335. if (k === feed.url) {
  1336. return true;
  1337. }
  1338. })) {
  1339. userCache.some(k => {
  1340. try {
  1341. var reg = new RegExp(k.url);
  1342. if (k.url && (reg.test(c.itemURL) || reg.test(feed.url))) {
  1343. check(true);
  1344. return true;
  1345. }
  1346. } catch (er2) {
  1347. console.log('SITEINFO Error: ', k.url);
  1348. }
  1349. });
  1350. }
  1351. }
  1352. if (!bFound) {
  1353. siteInfo.some(ctx => {
  1354. if (cacheInfo[ctx.url]) {
  1355. cacheInfo[ctx.url].info.some(k => {
  1356. try {
  1357. var reg = new RegExp(k.url);
  1358. if (k.url && (reg.test(c.itemURL) || reg.test(feed.url))) {
  1359. check(true);
  1360. return true;
  1361. }
  1362. } catch (er3) {
  1363. console.log('SITEINFO Error: ', k.url);
  1364. }
  1365. });
  1366. }
  1367. });
  1368. }
  1369. if (!bFound && /^https?:\/\/rss\.rssad\.jp\/rss\/.+/i.test(c.itemURL)) {
  1370. var opt = {
  1371. method: 'HEAD',
  1372. url: c.itemURL,
  1373. timeout: st.timeout * 1000,
  1374. onload: function(res) {
  1375. window.clearTimeout(xhrID);
  1376. if (res.status === 200 && res.finalUrl) {
  1377. c.itemURL = res.finalUrl;
  1378. var atl = document.querySelector(`${currentEntry()} .article_title_link`),
  1379. hbl = document.querySelector(`${currentEntry()} a[id^="aurl_"]`);
  1380. if (atl && atl.href) atl.href = res.finalUrl;
  1381. if (hbl && hbl.href) hbl.href = res.finalUrl;
  1382. if (/^https?:\/\/rss\.rssad\.jp\/rss\/.+/i.test(res.finalUrl)) check();
  1383. else FullFeed.registerWidgets();
  1384. } else check();
  1385. },
  1386. onerror: function() {
  1387. window.clearTimeout(xhrID);
  1388. check();
  1389. }
  1390. };
  1391. xhr.push(GM_xmlhttpRequest(opt));
  1392. xhrID = window.setTimeout(() => {
  1393. window.clearTimeout(xhrID);
  1394. for (var x1 = 0, x2 = xhr.length; x1 < x2; x1++) {
  1395. if (xhr[x1]) xhr[x1].abort();
  1396. }
  1397. xhr.length = 0;
  1398. }, st.timeout * 1000);
  1399. } else if (!bFound) check();
  1400. };
  1401.  
  1402. FullFeed.registerSocialIcons = function() {
  1403. if (!st.socialicon) return;
  1404. var c = new GetCurrentItem();
  1405. if (!c.innerContents) return;
  1406. if (document.querySelector(`${currentEntry()} .article_title > .irff_socialicon`)) return;
  1407. var container = document.querySelector(`${currentEntry()} .article_title`),
  1408. itemScheme = c.itemURL.slice(0, c.itemURL.indexOf('://') + 3),
  1409. itemUrl2 = c.itemURL.slice(c.itemURL.indexOf('://') + 3).replace(/#/g, '%23');
  1410. if (!container) return;
  1411. var twitter = {
  1412. method: 'get',
  1413. url: `http://urls.api.twitter.com/1/urls/count.json?url=${c.itemURL}`,
  1414. onload: function(res) {
  1415. if (res.status === 200) {
  1416. var info;
  1417. try {
  1418. info = JSON.parse(res.responseText);
  1419. } catch (er) {
  1420. return;
  1421. }
  1422. var total = info.count;
  1423. if (isNaN(total) || total <= 0) return;
  1424. var style = (total < 10) ? '1' :
  1425. (total < 100) ? '2' :
  1426. (total < 1000) ? '3' : '4',
  1427. str = (total > 1) ? 's' : '';
  1428. sT.innerHTML = `<a href="http://topsy.com/${itemUrl2}" target="_blank" title="Twitter: ${total} tweet${str}" class="irff_twitter irff_twitter${style}"><img src="https://twitter.com/favicon.ico"><span>${total}</span></a>`;
  1429. }
  1430. }
  1431. };
  1432. var delicious = {
  1433. method: 'get',
  1434. url: `http://badges.del.icio.us/feeds/json/url/data?url=${encodeURIComponent(c.itemURL)}`,
  1435. onload: function(res) {
  1436. if (res.status === 200) {
  1437. var info;
  1438. try {
  1439. info = JSON.parse(res.responseText);
  1440. } catch (er) {
  1441. return;
  1442. }
  1443. if (!info || !info.length) return;
  1444. var total = info[0].total_posts;
  1445. if (isNaN(total) || total <= 0) return;
  1446. var style = (total < 10) ? '1' :
  1447. (total < 100) ? '2' :
  1448. (total < 1000) ? '3' : '4',
  1449. str = (total > 1) ? ' people' : ' person';
  1450. sD.innerHTML = `<a href="http://delicious.com/url?url=${info[0].url}" target="_blank" title="Delicious: ${total}${str}" class="irff_delicious irff_delicious${style}"><img src="https://delicious.com/img/favicon.ico"><span>${total}</span></a>`;
  1451. }
  1452. }
  1453. };
  1454. var facebook = {
  1455. method: 'get',
  1456. url: `https://graph.facebook.com/${encodeURIComponent(c.itemURL)}`,
  1457. onload: function(res) {
  1458. if (res.status === 200) {
  1459. var info;
  1460. try {
  1461. info = JSON.parse(res.responseText);
  1462. } catch (er) {
  1463. return;
  1464. }
  1465. var total = info.shares;
  1466. if (!total || isNaN(total) || total <= 0) return;
  1467. sF.innerHTML = `<span title="Facebook: ${total} share${ total >= 2 ? 's' : '' }" class="irff_facebook"><img src="https://www.facebook.com/favicon.ico"><span>${total}</span></span>`;
  1468. }
  1469. }
  1470. };
  1471. var hatena = {
  1472. method: 'get',
  1473. url: `http://api.b.st-hatena.com/entry.count?url=${itemScheme}${itemUrl2}`,
  1474. onload: function(res) {
  1475. if (res.status === 200) {
  1476. var total = Number(res.responseText);
  1477. if (isNaN(total) || total <= 0) return;
  1478. var style = (total < 10) ? '1' :
  1479. (total < 100) ? '2' :
  1480. (total < 1000) ? '3' : '4',
  1481. str = (total > 1) ? ' users' : ' user',
  1482. ssl = (itemScheme === 'https://') ? 's/' : '';
  1483. sH.innerHTML = `<a href="http://b.hatena.ne.jp/entry/${ssl}${itemUrl2}" target="_blank" title="${LOC.t58}: ${total}${str}" class="irff_hatena irff_hatena${style}"><img src="http://b.hatena.ne.jp/favicon.ico"><span>${total}</span></a>`;
  1484. }
  1485. }
  1486. };
  1487.  
  1488. var googleplus = {
  1489. method: 'get',
  1490. url: `https://plusone.google.com/_/+1/fastbutton?url=${encodeURIComponent(c.itemURL)}`,
  1491. onload: function(res) {
  1492. if (res.status === 200) {
  1493. var text = res.responseText;
  1494. if (!text) return;
  1495. var total = text.match(/window\.__SSR\s*=\s*\{.*c:\s*(\d+)\.0/);
  1496. if (!total || total.length !== 2) return;
  1497. sG.innerHTML = `<span title="Google+: ${total[1]} share${ Number(total[1]) >= 2 ? 's' : '' }" class="irff_googleplus"><img src="https://www.google.com/favicon.ico"><span>${total[1]}</span></span>`;
  1498. }
  1499. }
  1500. };
  1501.  
  1502. var yahoo = `<a href="http://bookmarks.yahoo.co.jp/url?url=${encodeURIComponent(c.itemURL)}" target="_blank"><img src="http://num.bookmarks.yahoo.co.jp/image/small/${c.itemURL}" title="${LOC.t56}"/></a>`,
  1503. buzzurl = `<a href="http://buzzurl.jp/entry/${c.itemURL}" target="_blank"><img src="http://api.buzzurl.jp/api/counter/v1/image?url=${encodeURIComponent(c.itemURL)}" title="${LOC.t57}"/></a>`;
  1504. var ce = function() {
  1505. return document.createElement('span');
  1506. };
  1507. var sT = ce(),
  1508. sD = ce(),
  1509. sF = ce(),
  1510. sH = ce(),
  1511. sG = ce(),
  1512. sL = ce(),
  1513. sY = ce(),
  1514. sB = ce(),
  1515. sC = ce();
  1516. [sT, sD, sF, sH, sG, sL, sY, sB, sC].forEach(i => i.className = 'irff_socialicon');
  1517. var ac1 = function(s, f) {
  1518. container.appendChild(s);
  1519. GM_xmlhttpRequest(f);
  1520. };
  1521. var ac2 = function(s, f) {
  1522. s.innerHTML = f;
  1523. container.appendChild(s);
  1524. };
  1525. if (st.socialtwitter) ac1(sT, twitter);
  1526. if (st.socialdelicious) ac1(sD, delicious);
  1527. if (st.socialfacebook) ac1(sF, facebook);
  1528. if (st.socialgoogleplus) ac1(sG, googleplus);
  1529. if (st.socialhatena) ac1(sH, hatena);
  1530. if (st.socialyahoo) ac2(sY, yahoo);
  1531. if (st.socialbuzzurl) ac2(sB, buzzurl);
  1532. var repeat = 0,
  1533. inter;
  1534. var check = function() {
  1535. var e = document.querySelectorAll(`${currentEntry()} .article_title > .irff_socialicon > a > img`),
  1536. f = true;
  1537. repeat += 1;
  1538. for (var i = 0, j = e.length; i < j; i++) {
  1539. if (e[i].clientHeight === 1) i.parentNode.parentNode.removeChild(e[i].parentNode);
  1540. else if (e[i].clientHeight === 0 && repeat < 10) f = false;
  1541. }
  1542. if (f) window.clearInterval(inter);
  1543. };
  1544. inter = window.setInterval(() => check(), 1000);
  1545. };
  1546.  
  1547. FullFeed.documentFilters = [
  1548. function(doc) {
  1549. var a = doc.getElementsByTagName('a');
  1550. for (var i = 0, j = a.length; i < j; i++) {
  1551. if (a[i] && a[i].hasAttribute('href')) {
  1552. a[i].setAttribute('target', '_blank');
  1553. a[i].setAttribute('rel', 'noopener noreferrer');
  1554. }
  1555. }
  1556. }
  1557. ];
  1558.  
  1559. var getActiveItem = function() {
  1560. var item = {},
  1561. exp = document.querySelector(`${currentEntry()} .article_title_link`);
  1562. if (exp) {
  1563. item.url = (exp.href && /^(https?|ftp):\/\/.+$/.test(exp.href)) ? exp.href : '';
  1564. item.title = (exp.textContent) ? exp.textContent : '';
  1565. item.id = (exp.id) ? exp.id.slice(exp.id.lastIndexOf('_') + 1) : '';
  1566. }
  1567. return item;
  1568. };
  1569.  
  1570. var getActiveFeed = function() {
  1571. var eCurrent = document.querySelector(currentEntry()),
  1572. feed = {};
  1573. feed.url = '';
  1574. feed.title = '';
  1575. if (eCurrent && eCurrent.id) {
  1576. var eFeed = $id(`article_feed_info_link_${ eCurrent.id.slice(eCurrent.id.lastIndexOf('_') + 1)}`) ||
  1577. eCurrent.getElementsByClassName('article_feed_title')[0] ||
  1578. document.evaluate('//div[@class="article_tile_footer_feed_title"]/a', eCurrent.cloneNode(true), null, 9, null).singleNodeValue;
  1579. if (eFeed) {
  1580. if (eFeed.textContent) feed.title = eFeed.textContent;
  1581. } else if ($id('tree')) {
  1582. var tlf = $id('tree').getElementsByClassName('selected')[0];
  1583. if (tlf && tlf.textContent) feed.title = tlf.textContent;
  1584. }
  1585. }
  1586. if (feed.title) feed.title = feed.title.replace(/^\s*(.*?)\s*$/, '$1');
  1587. return feed;
  1588. };
  1589.  
  1590. var GetCurrentItem = function() {
  1591. this.item = getActiveItem(true);
  1592. this.feed = getActiveFeed();
  1593. this.itemURL = this.item.url;
  1594. this.articleContainer = document.querySelector(currentEntry());
  1595. this.innerContents = document.querySelector(`${currentEntry()} .article_content`);
  1596. this.found = false;
  1597. };
  1598.  
  1599. var launchFullFeed = function(list, c, flag) {
  1600. if (typeof list.some !== 'function') return;
  1601. state = 'launch';
  1602. itemSiteInfo.length = 0;
  1603. var type = ['^IND', '^SUB', '^GEN'],
  1604. bCache, bList;
  1605. var check = function(lis) {
  1606. lis.forEach(i => {
  1607. try {
  1608. var reg = new RegExp(i.url);
  1609. if (i.url && (i.url.length <= 12 || !/^\^?https?/i.test(i.url))) {
  1610. if (new RegExp('^://', 'i').test(i.url)) i.url = `^https?${i.url}`;
  1611. else if (new RegExp('^//', 'i').test(i.url)) i.url = `^https?:${i.url}`;
  1612. else i.url = `^https?://${i.url}`;
  1613. }
  1614. if (reg.test(c.itemURL) && i.url.length > 12) {
  1615. if (flag === 'cache') {
  1616. if (userCacheList.some(u => {
  1617. if (u === c.feed.url) return true;
  1618. })) {
  1619. c.found = true;
  1620. itemSiteInfo.push(i);
  1621. }
  1622. } else {
  1623. c.found = true;
  1624. itemSiteInfo.push(i);
  1625. }
  1626. }
  1627. } catch (er1) {
  1628. console.log('SITEINFO Error: ', i.url);
  1629. }
  1630. });
  1631. };
  1632. check(list);
  1633. if (/^next|^search/.test(flag)) {
  1634. if (!c.found) {
  1635. siteInfoAP.some(ctx => {
  1636. if (cacheAPInfo[ctx.url]) {
  1637. check(cacheAPInfo[ctx.url].info);
  1638. return c.found;
  1639. }
  1640. });
  1641. }
  1642. if (!c.found) {
  1643. check([{
  1644. 'url': nextPageLink.href,
  1645. 'xpath': ''
  1646. }]);
  1647. }
  1648. }
  1649. nextPageLink = null;
  1650. itemSiteInfo.sort((a, b) => {
  1651. var reA = new RegExp(a.url),
  1652. reB = new RegExp(b.url),
  1653. a1 = (reA.test(c.itemURL)) ? reA.source.length : 0,
  1654. b1 = (reB.test(c.itemURL)) ? reB.source.length : 0,
  1655. a2 = (reA.test(c.feed.url)) ? reA.source.length : 0,
  1656. b2 = (reB.test(c.feed.url)) ? reB.source.length : 0;
  1657. if (a.url.search(/\\w|\.\+|\.\*|\[\^\.?\/?\]\+/) !== -1) return true;
  1658. else if (b.url.search(/\\w|\.\+|\.\*|\[\^\.?\/?\]\+/) !== -1) return false;
  1659. return ((b1 >= b2) ? b1 : b2) - ((a1 >= a2) ? a1 : a2);
  1660. });
  1661. itemSiteInfo.sort((a, b) => {
  1662. var n1 = 0,
  1663. n2 = 0;
  1664. type.forEach((d, i) => {
  1665. if (new RegExp(d).test(a.type)) n1 = i;
  1666. if (new RegExp(d).test(b.type)) n2 = i;
  1667. });
  1668. return n1 - n2;
  1669. });
  1670. if (flag === 'full') {
  1671. if (!bCache && itemSiteInfo.length > 0) {
  1672. userCache.some(u => {
  1673. if (u === itemSiteInfo[0]) {
  1674. bCache = true;
  1675. return true;
  1676. }
  1677. });
  1678. userCacheList.some(u => {
  1679. if (u === c.feed.url) {
  1680. bList = true;
  1681. return true;
  1682. }
  1683. });
  1684. if (!bCache) {
  1685. delete itemSiteInfo[0].base;
  1686. delete itemSiteInfo[0].microformats;
  1687. delete itemSiteInfo[0].priority;
  1688. userCache.push(itemSiteInfo[0]);
  1689. try {
  1690. localStorage.setItem('InoReaderFullFeed_userCache', JSON.stringify(userCache));
  1691. } catch (er2) { console.error(er2); }
  1692. }
  1693. if (!bList) {
  1694. userCacheList.push(c.feed.url);
  1695. try {
  1696. localStorage.setItem('InoReaderFullFeed_userCacheList', JSON.stringify(userCacheList));
  1697. } catch (er3) { console.error(er3); }
  1698. }
  1699. }
  1700. }
  1701. if (c.found && itemSiteInfo.length > 0) {
  1702. var data, bool;
  1703. if (itemSiteInfo.some(a => {
  1704. data = a;
  1705. bool = true;
  1706. st.disableitem.forEach(b => {
  1707. if (a.url === b) bool = false;
  1708. });
  1709. if (bool) return true;
  1710. })) new FullFeed(data, c, flag);
  1711. else new FullFeed(itemSiteInfo[0], c, flag);
  1712. } else state = null;
  1713. };
  1714.  
  1715. var initFullFeed = function(scroll) {
  1716. var c = new GetCurrentItem();
  1717. if (/^https?:\/\/(?:www\.)?inoreader\.com\/?$|^javascript:|\.pdf$/i.test(c.itemURL)) return;
  1718. if (state && !/^loaded$|^wait$/.test(state)) {
  1719. for (var x1 = 0, x2 = xhr.length; x1 < x2; x1++) {
  1720. if (xhr[x1]) xhr[x1].abort();
  1721. }
  1722. xhr.length = 0;
  1723. state = null;
  1724. message(LOC.t82, 3000, 'warning');
  1725. if (c.itemInfo) {
  1726. loadingStyle('remove', c.itemInfo.articleContainer);
  1727. c.itemInfo.innerContents.classList.add('irff_error');
  1728. }
  1729. return;
  1730. }
  1731. if ((state && !/^loaded$|^wait$/.test(state)) || !c.item.title || !c.item.url || !c.innerContents) return;
  1732. message(LOC.t54, -1);
  1733. if (st.notread) {
  1734. var re = new RegExp(st.notread);
  1735. if (re.test(c.item.title) || re.test(c.item.url) || re.test(c.feed.title)) {
  1736. if (st.openitem) {
  1737. loadingStyle('open', c.articleContainer);
  1738. GM_openInTab(c.itemURL, true);
  1739. window.setTimeout(() => loadingStyle('remove', c.articleContainer), 1000);
  1740. return message(LOC.t49, 2000);
  1741. }
  1742. return message(LOC.t8);
  1743. }
  1744. }
  1745. var launch = function() {
  1746. if (c.innerContents && c.innerContents.classList.contains('irff_loaded')) {
  1747. if (st.autopagerize) {
  1748. FullFeed.checkNextPage(c.innerContents);
  1749. if (nextPageLink) {
  1750. c.itemURL = nextPageLink.href;
  1751. launchFullFeed(userSiteInfo, c, 'set');
  1752. if (!c.found) launchFullFeed(userCache, c, 'cache');
  1753. if (!c.found) {
  1754. siteInfo.some(ctx => {
  1755. if (cacheInfo[ctx.url]) {
  1756. launchFullFeed(cacheInfo[ctx.url].info, c, 'next');
  1757. return c.found;
  1758. }
  1759. });
  1760. }
  1761. if (!c.found) launchFullFeed([], c, 'search');
  1762. loadingStyle('add', c.articleContainer);
  1763. return message(LOC.t4, -1);
  1764. } else if (!scroll) {
  1765. if (c.innerContents.className.split(/\s+/).filter(i => /^http/.test(i)).length > 1) return message(LOC.t7);
  1766. return message(LOC.t9);
  1767. }
  1768. } else if (!scroll) return message(LOC.t9);
  1769. } else {
  1770. if (scroll) return;
  1771. launchFullFeed(userSiteInfo, c, 'set');
  1772. if (!c.found) launchFullFeed(userCache, c, 'cache');
  1773. if (!c.found && !siteInfo.some(ctx => {
  1774. if (cacheInfo[ctx.url]) {
  1775. launchFullFeed(cacheInfo[ctx.url].info, c, 'full');
  1776. return c.found;
  1777. }
  1778. })) new FullFeed({}, c, 'search');
  1779. }
  1780. };
  1781. var longurl = function(u) {
  1782. GM_xmlhttpRequest({
  1783. method: 'get',
  1784. url: `http://api.longurl.org/v2/expand?format=json&url=${u}`,
  1785. onload: function(res) {
  1786. if (res.status === 200) {
  1787. try {
  1788. var longUrl = JSON.parse(res.responseText)['long-url'];
  1789. if (longUrl && /^https?:/.test(longUrl) && longUrl.replace('\\/', '/') !== c.itemURL) {
  1790. c.itemURL = c.feed.url = longUrl;
  1791. checkShortUrl();
  1792. } else unshortenit(u);
  1793. } catch (er) {
  1794. unshortenit(u);
  1795. }
  1796. } else unshortenit(u);
  1797. },
  1798. onerror: function() {
  1799. unshortenit(u);
  1800. }
  1801. });
  1802. };
  1803. var unshortenit = function(u) {
  1804. GM_xmlhttpRequest({
  1805. method: 'get',
  1806. url: `http://www.unshorten.it/api1.0.php?responseFormat=text&shortURL=${u}`,
  1807. onload: function(res) {
  1808. if (res.status === 200) {
  1809. try {
  1810. var longUrl = res.responseText;
  1811. if (longUrl && /^https?:/.test(longUrl)) {
  1812. c.itemURL = c.feed.url = longUrl;
  1813. } else checkShortUrl();
  1814. } catch (er) { console.error(er); }
  1815. checkShortUrl();
  1816. }
  1817. },
  1818. onerror: function() {
  1819. checkShortUrl();
  1820. }
  1821. });
  1822. };
  1823. var checkShortUrl = function() {
  1824. if (c.itemURL !== tempUrl) {
  1825. tempUrl = c.itemURL;
  1826. GM_xmlhttpRequest({
  1827. method: 'HEAD',
  1828. url: c.itemURL,
  1829. onload: function(res) {
  1830. if (res.status === 200 && res.finalUrl) {
  1831. if (/^https?:\/\/t.co\/.+/.test(res.finalUrl)) longurl(res.finalUrl);
  1832. else {
  1833. c.itemURL = c.feed.url = res.finalUrl;
  1834. launch();
  1835. }
  1836. } else if (((res.status >= 301 && res.status <= 303) || res.status === 307) && res.finalUrl) {
  1837. if (['t.co', 'bit.ly', 'goo.gl', 'is.gd', 'j.mp', 'ow.ly', 'tinyurl.com'].some(a => {
  1838. if (new RegExp(`^https?://${a}/.+`).test(res.finalUrl)) return true;
  1839. })) longurl(res.finalUrl);
  1840. else unshortenit(res.finalUrl);
  1841. } else launch();
  1842. },
  1843. onerror: function() {
  1844. launch();
  1845. }
  1846. });
  1847. } else launch();
  1848. };
  1849. if (!st.replacefullfeedurl) {
  1850. launch();
  1851. return;
  1852. }
  1853. var tempUrl = c.itemURL,
  1854. rep = st.replacefullfeedurl.replace(/\s+/g, ' ').split(' ');
  1855. if (rep.length >= 2) {
  1856. var excludeUrl = function(e) {
  1857. e.some(a => {
  1858. if (a.href.split('/')[2].indexOf('xn--') === -1 && /^https?:\/\/.+/.test(a.textContent)) {
  1859. c.itemURL = c.feed.url = a.href;
  1860. }
  1861. });
  1862. };
  1863. for (var i = 0, j = rep.length - 1; i < j; i = i + 2) {
  1864. if (rep[i] && new RegExp(rep[i]).test(c.itemURL)) {
  1865. if (rep[i + 1] && /^http/.test(rep[i + 1])) {
  1866. c.itemURL = c.itemURL.replace(new RegExp(rep[i]), rep[i + 1]);
  1867. c.feed.url = c.itemURL;
  1868. } else if (rep[i + 1] === 'Link') {
  1869. try {
  1870. var u = document.querySelectorAll(`${currentEntry()} .article_content a`);
  1871. if (u) excludeUrl(u);
  1872. } catch (er) { console.error(er); }
  1873. }
  1874. break;
  1875. }
  1876. }
  1877. } else launch();
  1878. checkShortUrl();
  1879. };
  1880.  
  1881. var loadingStyle = function(flag, elm) {
  1882. if (!elm) return;
  1883. var s1 = 'irff_loading',
  1884. s2 = 'irff_opened';
  1885. if (flag === 'add') elm.classList.add(s1);
  1886. else if (flag === 'open') elm.classList.add(s2);
  1887. else if (flag === 'remove') {
  1888. elm.classList.remove(s1);
  1889. elm.classList.remove(s2);
  1890. }
  1891. };
  1892.  
  1893. var createMessageBox = function() {
  1894. var div = document.createElement('div');
  1895. div.id = 'irff_message';
  1896. div.className = 'ui-state-highlight irff_hidden';
  1897. div.innerHTML = '';
  1898. document.body.appendChild(div);
  1899. };
  1900.  
  1901. var currentEntry = function() {
  1902. if ($id('article_dialog')) {
  1903. return '#article_dialog > .article_full_contents';
  1904. }
  1905. if ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none' && $id('reader_pane').getElementsByClassName('article_current article_current_3way')[0]) {
  1906. return '#three_way_contents > .article_full_contents:last-child';
  1907. }
  1908. if ($id('subscriptions_articles')) {
  1909. return '#subscriptions_articles > .article_current';
  1910. }
  1911. return '#reader_pane .article_current';
  1912. };
  1913.  
  1914. var toggleSettingsMode = function() {
  1915. var adv = $id('irff_s').getElementsByClassName('irff_s-advance');
  1916. for (var i = 0, j = adv.length; i < j; i++) {
  1917. if (adv[i]) adv[i].classList.toggle('irff_hidden');
  1918. }
  1919. if (st.mode === 'simple' && !$ids('siteinfo_navi_uff').classList.contains('select') &&
  1920. !$ids('siteinfo_navi_uap').classList.contains('select')) {
  1921. var el1 = $ids('siteinfo').getElementsByTagName('fieldset');
  1922. for (var i1 = 0, j1 = el1.length; i1 < j1; i1++) {
  1923. el1[i1].classList.remove('select');
  1924. }
  1925. var el2 = document.getElementsByClassName('irff_s-siteinfo_navi');
  1926. for (var i2 = 0, j2 = el2.length; i2 < j2; i2++) {
  1927. el2[i2].classList.remove('select');
  1928. }
  1929. $ids('siteinfo_navi_uff').classList.add('select');
  1930. $ids('siteinfo_f_uff').classList.add('select');
  1931. }
  1932. };
  1933.  
  1934. var loadTwitterWidgetsScript = function() {
  1935. if (st.embeddedtweets) {
  1936. var sc = document.getElementsByTagName('script'),
  1937. fl = true;
  1938. for (var i = 0, j = sc.length; i < j; i++) {
  1939. if (sc[i].src && /^https:\/\/platform\.twitter\.com\/widgets\.js/.test(sc[i].src)) {
  1940. fl = false;
  1941. break;
  1942. }
  1943. }
  1944. if (fl) {
  1945. var script = document.createElement('script');
  1946. script.type = 'text/javascript';
  1947. script.src = 'https://platform.twitter.com/widgets.js';
  1948. document.getElementsByTagName('head')[0].appendChild(script);
  1949. }
  1950. }
  1951. };
  1952.  
  1953. var exportSettings = function() {
  1954. var settings = localStorage.getItem('InoReaderFullFeed_settings');
  1955. if (typeof GM_setClipboard === 'function') {
  1956. if (window.confirm(LOC.t66)) {
  1957. GM_setClipboard(settings);
  1958. message(LOC.t67, 3000);
  1959. }
  1960. } else {
  1961. var eTemp = document.createElement('div'),
  1962. result;
  1963. eTemp.id = 'irff_temp';
  1964. eTemp.innerHTML = '<div id="irff_temp-bar"><div id="irff_temp-bar_title">Export Data</div><div id="irff_temp-bar_button"><input id="irff_temp-close" type="button" value="Close"></div></div><div id="irff_temp-body"><textarea id="irff_temp-textarea"></div>';
  1965. document.body.appendChild(eTemp);
  1966. $id('irff_temp-close').addEventListener('click', () => {
  1967. document.body.removeChild($id('irff_temp'));
  1968. }, false);
  1969. $id('irff_temp-textarea').textContent = settings;
  1970. document.getSelection().selectAllChildren($id('irff_temp-textarea'));
  1971. result = document.execCommand('copy');
  1972. if (result) {
  1973. document.body.removeChild(eTemp);
  1974. message(LOC.t67, 3000);
  1975. } else {
  1976. eTemp.style.visibility = 'visible';
  1977. message(LOC.t68, 3000);
  1978. }
  1979. }
  1980. };
  1981.  
  1982. var debugLog = false,
  1983. itemSiteInfo = [],
  1984. xhr = [],
  1985. nextPageLink = null,
  1986. readingPageUrl = null,
  1987. state = null,
  1988. messageInterval, scrollInterval, initInterval,
  1989. st, siteInfo, siteInfoAP, userSiteInfo, userSiteInfoAP,
  1990. cacheInfo, cacheAPInfo, userCache, userCacheAP, userCacheList, userCacheListAP;
  1991.  
  1992. var init = function() {
  1993. var nCheck = 0,
  1994. exSpaceKey, exSpaceCode, iIrkc;
  1995. FullFeed.loadSettings();
  1996. cacheInfo = FullFeed.getCache('cache');
  1997. cacheAPInfo = FullFeed.getCache('cacheAP');
  1998. userCache = FullFeed.getCache('userCache');
  1999. userCacheAP = FullFeed.getCache('userCacheAP');
  2000. userCacheList = FullFeed.getCache('userCacheList');
  2001. userCacheListAP = FullFeed.getCache('userCacheListAP');
  2002. if (GM_registerMenuCommand && typeof GM_registerMenuCommand === 'function') {
  2003. GM_registerMenuCommand('InoReader Full Feed - reset cache', () => {
  2004. if (window.confirm(LOC.t15)) FullFeed.resetCache();
  2005. });
  2006. GM_registerMenuCommand('InoReader Full Feed - delete cache', () => FullFeed.removeCache());
  2007. }
  2008. GM_addStyle(CSS);
  2009. FullFeed.createSettings();
  2010. createMessageBox();
  2011. var exKey = function() {
  2012. if ($id('irkc_key-space')) {
  2013. exSpaceKey = $id('irkc_key-space').value;
  2014. if (exSpaceKey) {
  2015. exSpaceCode = (/^[%&]$/.test(exSpaceKey)) ? 32 : exSpaceKey.toUpperCase().charCodeAt(0);
  2016. }
  2017. }
  2018. };
  2019. var checkIrkc = function() {
  2020. if ($id('irkc_ok')) {
  2021. window.clearInterval(iIrkc);
  2022. $id('irkc_ok').addEventListener('click', e => {
  2023. exKey();
  2024. e.stopPropagation();
  2025. }, false);
  2026. exKey();
  2027. } else if (nCheck < 99) nCheck += 1;
  2028. else window.clearInterval(iIrkc);
  2029. };
  2030. iIrkc = window.setInterval(() => checkIrkc(), 250);
  2031. document.addEventListener('keydown', e => {
  2032. if (state && !/^loaded$|^wait$/.test(state) && !/^input|^textarea/i.test(e.target.tagName) && ((e.keyCode === 32 && exSpaceKey !== '&') || (exSpaceKey && e.keyCode === exSpaceCode))) {
  2033. var rp = $id('reader_pane'),
  2034. ad = $id('article_dialog'),
  2035. twc = $id('three_way_contents'),
  2036. ce = document.querySelector(currentEntry());
  2037. if (!ce) return;
  2038. var eTop = (twc && twc.style.display !== 'none' ? twc : ad ? ad : rp),
  2039. eHeight = (twc && twc.style.display !== 'none' ? twc : ad ? ad : ce),
  2040. bottom = (twc && twc.style.display !== 'none' ? twc.clientHeight : ad ? ad.clientHeight + 70 : rp.clientHeight) + eTop.scrollTop - ce.offsetTop - eHeight.scrollHeight;
  2041. if (bottom >= 0) {
  2042. e.preventDefault();
  2043. e.stopPropagation();
  2044. }
  2045. }
  2046. }, true);
  2047. document.addEventListener('keyup', e => {
  2048. var key = (isNaN(st.basekey)) ? st.basekey.toUpperCase().charCodeAt(0) : Number(st.basekey),
  2049. el1 = $ids('general_key'),
  2050. el2, el3;
  2051. if (e.target.id === 'irff_s-general_key') {
  2052. el2 = $ids('general_keydesc');
  2053. var code = e.keyCode,
  2054. cha = String.fromCharCode(code);
  2055. if (/[A-Z]/.test(cha)) {
  2056. el1.value = cha;
  2057. el2.textContent = LOC.t24;
  2058. } else if (code < 16 || code > 18) {
  2059. el1.value = code;
  2060. el2.textContent = LOC.t25;
  2061. }
  2062. } else if (e.keyCode === key && !/^input|^textarea/i.test(e.target.tagName)) {
  2063. if (e.altKey && e.ctrlKey && e.shiftKey) {
  2064. if (window.confirm(LOC.t15)) FullFeed.resetCache();
  2065. } else if (e.ctrlKey && e.shiftKey) {
  2066. el3 = document.querySelector(currentEntry());
  2067. if (el3 && (el3.classList.contains('article_full_contents') ||
  2068. (el3.classList.contains('ar') &&
  2069. el3.classList.contains('article_current')))) FullFeed.viewSettings('autoload');
  2070. else FullFeed.viewSettings();
  2071. } else if (e.ctrlKey) {
  2072. if (st.autoload === 0) st.autoload = 1;
  2073. else if (st.autoload === 1) st.autoload = 2;
  2074. else if (st.autoload === 2) st.autoload = 3;
  2075. else st.autoload = 0;
  2076. FullFeed.saveSettings();
  2077. message(`Auto Load : ${ (st.autoload === 0) ? LOC.t36 : (st.autoload === 1) ? LOC.t77 : (st.autoload === 2) ? LOC.t45 : LOC.t46}`);
  2078. } else if (e.shiftKey) {
  2079. st.autopagerize = !st.autopagerize;
  2080. FullFeed.saveSettings();
  2081. message(`AutoPagerize : ${ (st.autopagerize) ? '<span class="irff_ap_on">ON</span>' : '<span class="irff_ap_off">OFF</span>'}`);
  2082. } else initFullFeed();
  2083. }
  2084. FullFeed.checkRegister();
  2085. }, false);
  2086. document.addEventListener('click', e => {
  2087. if (e.button >= 2) return;
  2088. var tId = e.target.id;
  2089. if (e.button === 0 && tId && /^irff_s-/.test(tId)) {
  2090. var settings = $id('irff_s'),
  2091. wlFeedTitle = $ids('autoload_whitelist_feed_title'),
  2092. wlFeedList = $ids('autoload_whitelist_feed_list'),
  2093. wlArticleTitle = $ids('autoload_whitelist_article_title'),
  2094. wlArticleList = $ids('autoload_whitelist_article_list'),
  2095. blFeedTitle = $ids('autoload_blacklist_feed_title'),
  2096. blFeedList = $ids('autoload_blacklist_feed_list'),
  2097. blArticleTitle = $ids('autoload_blacklist_article_title'),
  2098. blArticleList = $ids('autoload_blacklist_article_list');
  2099. if (tId === 'irff_s-menu') {
  2100. FullFeed.viewSettings();
  2101. } else if (tId === 'irff_s-menu2' || tId === 'irff_s-menu2child') {
  2102. $id('settings-button').blur();
  2103. FullFeed.viewSettings();
  2104. } else if (/^irff_s-tab_/.test(tId)) {
  2105. var tab = $ids('tab').childNodes,
  2106. list = $ids('list').childNodes;
  2107. for (var i = 0; i < tab.length; i++) {
  2108. if (tab[i].classList.contains('select')) {
  2109. tab[i].classList.remove('select');
  2110. list[i].style.display = 'none';
  2111. }
  2112. if (tab[i].textContent === e.target.textContent) {
  2113. tab[i].classList.add('select');
  2114. list[i].style.display = 'block';
  2115. }
  2116. }
  2117. } else if (tId === 'irff_s-general_keyhelpicon') {
  2118. if (e.target.nextSibling.style.display !== 'block') e.target.nextSibling.style.display = 'block';
  2119. else e.target.nextSibling.style.display = 'none';
  2120. } else if (e.target.classList && e.target.classList.contains('irff_s-siteinfo_navi')) {
  2121. var el3 = $ids('siteinfo').getElementsByTagName('fieldset');
  2122. for (var i1 = 0, j1 = el3.length; i1 < j1; i1++) {
  2123. el3[i1].classList.remove('select');
  2124. }
  2125. var el4 = document.getElementsByClassName('irff_s-siteinfo_navi');
  2126. for (var i2 = 0, j2 = el4.length; i2 < j2; i2++) {
  2127. el4[i2].classList.remove('select');
  2128. }
  2129. e.target.classList.add('select');
  2130. $ids(`siteinfo_f${tId.slice(tId.lastIndexOf('_'))}`).classList.add('select');
  2131. } else if (tId === 'irff_s-siteinfo_uff_add') {
  2132. var fUrl = $ids('siteinfo_uff_url').value.trim().replace(/"/g, '\''),
  2133. fXpath = $ids('siteinfo_uff_xpath').value.trim().replace(/"/g, '\''),
  2134. fType = $ids('siteinfo_uff_type').value.trim().replace(/"/g, '\''),
  2135. fEnc = $ids('siteinfo_uff_enc').value.trim().replace(/"/g, '\''),
  2136. fTa = $ids('siteinfo_uff').value.trim().replace(/(.+)\}\s*,?\s*\n\s*\]\s*$/, '$1}\n]'),
  2137. fForm = `\n {\n "url":"${fUrl}",\n "xpath":"${fXpath}",\n "type":"${fType}"`;
  2138. if (fEnc) fForm += `,\n "enc":"${fEnc}"`;
  2139. fForm += '\n }';
  2140. if (!fTa) $ids('siteinfo_uff').value = `[${fForm}\n]`;
  2141. else if (fTa.slice(-3) === '}\n]') $ids('siteinfo_uff').value = `${fTa.slice(0, -2) },${fForm}\n]`;
  2142. $ids('siteinfo_uff').scrollTop = $ids('siteinfo_uff').scrollHeight;
  2143. } else if (tId === 'irff_s-siteinfo_uap_add') {
  2144. var aUrl = $ids('siteinfo_uap_url').value.trim().replace(/"/g, '\''),
  2145. aNext = $ids('siteinfo_uap_nextlink').value.trim().replace(/"/g, '\''),
  2146. aPage = $ids('siteinfo_uap_pageelement').value.trim().replace(/"/g, '\''),
  2147. aTa = $ids('siteinfo_uap').value.trim().replace(/(.+)\}\s*,?\s*\n\s*\]\s*$/, '$1}\n]'),
  2148. aForm = `\n {\n "url":"${aUrl}",\n "nextLink":"${aNext}",\n "pageElement":"${aPage}"\n }`;
  2149. if (!aTa) $ids('siteinfo_uap').value = `[${aForm}\n]`;
  2150. else if (aTa.slice(-3) === '}\n]') $ids('siteinfo_uap').value = `${aTa.slice(0, -2) },${aForm}\n]`;
  2151. $ids('siteinfo_uap').scrollTop = $ids('siteinfo_uap').scrollHeight;
  2152. } else if (e.target.classList && e.target.classList.contains('irff_s-autoload_navi')) {
  2153. var el5 = $ids('autoload').getElementsByTagName('fieldset');
  2154. for (var i3 = 0, j3 = el5.length; i3 < j3; i3++) {
  2155. el5[i3].classList.remove('select');
  2156. }
  2157. var el6 = document.getElementsByClassName('irff_s-autoload_navi');
  2158. for (var i4 = 0, j4 = el6.length; i4 < j4; i4++) {
  2159. el6[i4].classList.remove('select');
  2160. }
  2161. e.target.classList.add('select');
  2162. $ids(`autoload_f${tId.slice(tId.lastIndexOf('_'))}`).classList.add('select');
  2163. } else if (tId === 'irff_s-autoload_whitelist_feed_add') {
  2164. if (wlFeedTitle.value) {
  2165. if (wlFeedList.value) wlFeedList.value += `\n${wlFeedTitle.value}`;
  2166. else wlFeedList.value = wlFeedTitle.value;
  2167. wlFeedTitle.value = null;
  2168. }
  2169. } else if (tId === 'irff_s-autoload_whitelist_article_add') {
  2170. if (wlArticleTitle.value) {
  2171. if (wlArticleList.value) wlArticleList.value += `\n${wlArticleTitle.value}`;
  2172. else wlArticleList.value = wlArticleTitle.value;
  2173. wlArticleTitle.value = null;
  2174. }
  2175. } else if (tId === 'irff_s-autoload_blacklist_feed_add') {
  2176. if (blFeedTitle.value) {
  2177. if (blFeedList.value) blFeedList.value += `\n${blFeedTitle.value}`;
  2178. else blFeedList.value = blFeedTitle.value;
  2179. blFeedTitle.value = null;
  2180. }
  2181. } else if (tId === 'irff_s-autoload_blacklist_article_add') {
  2182. if (blArticleTitle.value) {
  2183. if (blArticleList.value) blArticleList.value += `\n${blArticleTitle.value}`;
  2184. else blArticleList.value = blArticleTitle.value;
  2185. blArticleTitle.value = null;
  2186. }
  2187. } else if (tId === 'irff_s-security_iframetag') {
  2188. if ($ids('security_iframetag').checked) {
  2189. $ids('security_allowiframeurl').disabled = false;
  2190. $ids('security_allowiframeurl').parentNode.style.color = 'black';
  2191. } else {
  2192. $ids('security_allowiframeurl').disabled = true;
  2193. $ids('security_allowiframeurl').parentNode.style.color = 'gray';
  2194. }
  2195. } else if (tId === 'irff_s-social_socialicon') {
  2196. ['buzzurl', 'delicious', 'facebook', 'googleplus', 'hatena', 'twitter', 'yahoo'].forEach(a => {
  2197. if ($ids('social_socialicon').checked) {
  2198. $ids(`social_${a}`).disabled = false;
  2199. $ids(`social_${a}`).parentNode.style.color = 'black';
  2200. } else {
  2201. $ids(`social_${a}`).disabled = true;
  2202. $ids(`social_${a}`).parentNode.style.color = 'gray';
  2203. }
  2204. });
  2205. } else if (tId === 'irff_s-etc_settingsexport') {
  2206. exportSettings();
  2207. } else if (tId === 'irff_s-etc_settingsimport') {
  2208. var imp = window.prompt(LOC.t69);
  2209. try {
  2210. if (imp && imp.length > 100 && JSON.parse(imp)) {
  2211. FullFeed.loadSettings(JSON.parse(imp));
  2212. FullFeed.saveSettings();
  2213. settings.style.display = 'none';
  2214. message(LOC.t70, 3000);
  2215. }
  2216. } catch (er1) {
  2217. message(LOC.t71, 3000, 'warning');
  2218. }
  2219. } else if (tId === 'irff_s-etc_settingsreset') {
  2220. if (window.confirm(LOC.t72)) {
  2221. FullFeed.loadSettings('reset');
  2222. FullFeed.saveSettings();
  2223. settings.style.display = 'none';
  2224. message(LOC.t73, 3000);
  2225. }
  2226. } else if (tId === 'irff_s-etc_cachereset') {
  2227. if (window.confirm(LOC.t15)) FullFeed.resetCache();
  2228. } else if (tId === 'irff_s-etc_cachedelete') {
  2229. FullFeed.removeCache();
  2230. } else if (tId === 'irff_s-ok') {
  2231. var key = $ids('general_key'),
  2232. hei = $ids('general_apheight'),
  2233. v = key.value,
  2234. h = hei.value,
  2235. problem = false;
  2236. if (v && ((isNaN(v) && v.length === 1) || (!isNaN(v) && (v < 16 || v > 18)))) st.basekey = v;
  2237. st.autopagerize = $ids('general_ap').checked;
  2238. if (h && !isNaN(h)) st.apheight = (h < 200) ? 200 : (h > 2000) ? 2000 : h;
  2239. st.autosearch = $ids('general_autosearch').checked;
  2240. st.cantdisplay = $ids('general_cantdisplay').selectedIndex;
  2241. st.embeddedtweets = $ids('general_embeddedtweets').checked;
  2242. st.notread = $ids('general_notread').value;
  2243. st.openitem = $ids('general_openitem').checked;
  2244. var rep = function(str) {
  2245. return str.replace(/^(\s*\{)/, '[$1')
  2246. .replace(/(\}),?(\s*)$/, '$1$2]')
  2247. .replace(/\\\\/g, '\\')
  2248. .replace(/\\/g, '\\\\')
  2249. .replace(/\\\\\/\\\\\//g, '\\/\\/')
  2250. .replace(/"/g, '\'')
  2251. .replace(/(\{\s*|:\s*|'\s*,\s*|\}\s*,\s*)'/g, '$1"')
  2252. .replace(/'(\s*:|\s*,\s*"|\s*,?\s*\})/g, '"$1')
  2253. .replace(/("\s*),(\s*\})/g, '$1$2')
  2254. .replace(/\}(\s*)\{/g, '},$1{')
  2255. .replace(/\}\s*,?\s*\n\s*\]\s*$/, '}\n]')
  2256. .trim();
  2257. };
  2258. var siff = $ids('siteinfo_ff'),
  2259. siap = $ids('siteinfo_ap'),
  2260. siuff = $ids('siteinfo_uff'),
  2261. siuap = $ids('siteinfo_uap');
  2262. if (!siff.value) siff.value = '[{"format": "JSON", "url": "http://wedata.net/databases/LDRFullFeed/items.json"}]';
  2263. if (!siap.value) siap.value = '[{"format": "JSON", "url": "http://wedata.net/databases/AutoPagerize/items.json"}]';
  2264. if (!siuff.value) siuff.value = '[{"url": "", "xpath": "", "type": "", "enc": ""}]';
  2265. if (!siuap.value) siuap.value = '[{"url": "", "nextLink": "", "pageElement": ""}]';
  2266. try {
  2267. siteInfo = JSON.parse(rep(siff.value));
  2268. st.siteinfo = JSON.stringify(siteInfo);
  2269. siff.parentNode.style.backgroundColor = null;
  2270. } catch (er2) {
  2271. problem = true;
  2272. siff.parentNode.style.backgroundColor = '#FCC';
  2273. }
  2274. try {
  2275. siteInfoAP = JSON.parse(rep(siap.value));
  2276. st.siteinfoap = JSON.stringify(siteInfoAP);
  2277. siap.parentNode.style.backgroundColor = null;
  2278. } catch (er3) {
  2279. problem = true;
  2280. siap.parentNode.style.backgroundColor = '#FCC';
  2281. }
  2282. try {
  2283. userSiteInfo = JSON.parse(rep(siuff.value));
  2284. st.usersiteinfo = JSON.stringify(userSiteInfo);
  2285. siuff.parentNode.style.backgroundColor = null;
  2286. } catch (er4) {
  2287. problem = true;
  2288. siuff.parentNode.style.backgroundColor = '#FCC';
  2289. }
  2290. try {
  2291. userSiteInfoAP = JSON.parse(rep(siuap.value));
  2292. st.usersiteinfoap = JSON.stringify(userSiteInfoAP);
  2293. siuap.parentNode.style.backgroundColor = null;
  2294. } catch (er5) {
  2295. problem = true;
  2296. siuap.parentNode.style.backgroundColor = '#FCC';
  2297. }
  2298. var sidu = $ids('siteinfo_disableitem');
  2299. if (sidu) {
  2300. st.disableitem = sidu.value.split('\n').filter(k => {
  2301. if (k) return k;
  2302. });
  2303. }
  2304. st.autoload = $ids('autoload_mode').selectedIndex;
  2305. if (wlFeedList) {
  2306. st.autoloadfeed = wlFeedList.value.split('\n').filter(k => {
  2307. if (k) return k;
  2308. });
  2309. }
  2310. if (wlArticleList) {
  2311. st.autoloadarticle = wlArticleList.value.split('\n').filter(k => {
  2312. if (k) return k;
  2313. });
  2314. }
  2315. if (blFeedList) {
  2316. st.notloadfeed = blFeedList.value.split('\n').filter(k => {
  2317. if (k) return k;
  2318. });
  2319. }
  2320. if (blArticleList) {
  2321. st.notloadarticle = blArticleList.value.split('\n').filter(k => {
  2322. if (k) return k;
  2323. });
  2324. }
  2325. wlFeedTitle.value = null;
  2326. wlArticleTitle.value = null;
  2327. blFeedTitle.value = null;
  2328. blArticleTitle.value = null;
  2329. st.noscripttag = $ids('security_noscripttag').checked;
  2330. st.iframetag = $ids('security_iframetag').checked;
  2331. st.allowiframeurl = $ids('security_allowiframeurl').value;
  2332. st.denynexturl = $ids('security_denynexturl').value;
  2333. st.allownexturl = $ids('security_allownexturl').value;
  2334. st.socialicon = $ids('social_socialicon').checked;
  2335. st.socialbuzzurl = $ids('social_buzzurl').checked;
  2336. st.socialdelicious = $ids('social_delicious').checked;
  2337. st.socialfacebook = $ids('social_facebook').checked;
  2338. st.socialgoogleplus = $ids('social_googleplus').checked;
  2339. st.socialhatena = $ids('social_hatena').checked;
  2340. st.socialtwitter = $ids('social_twitter').checked;
  2341. st.socialyahoo = $ids('social_yahoo').checked;
  2342. var lla = $ids('etc_lazyloadattr');
  2343. if ($ids('etc_mode-simple').checked) st.mode = 'simple';
  2344. else if ($ids('etc_mode-advance').checked) st.mode = 'advance';
  2345. if (lla.value) lla.value = lla.value.trim().replace(/^(.+),+$/, '$1');
  2346. else lla.value = '"ajax","data-lazy-src","data-original","data-src"';
  2347. st.timeout = $ids('etc_timeout').value;
  2348. st.replacefullfeedurl = $ids('etc_replacefullfeedurl').value;
  2349. st.lazyloadurl = $ids('etc_lazyloadurl').value;
  2350. st.lazyloadattr = lla.value;
  2351. debugLog = $ids('etc_debuglog').checked;
  2352. if (!problem) {
  2353. $ids('ok').blur();
  2354. settings.style.display = 'none';
  2355. FullFeed.saveSettings();
  2356. loadTwitterWidgetsScript();
  2357. }
  2358. } else if (tId === 'irff_s-cancel') {
  2359. $ids('cancel').blur();
  2360. settings.style.display = 'none';
  2361. }
  2362. } else if (e.target.classList && e.target.classList.contains('irff_checked_icon')) {
  2363. if ((e.button === 0 && e.ctrlKey) || e.button === 1) FullFeed.viewSettings('autoload', e.target);
  2364. else if (e.button === 0) initFullFeed();
  2365. } else if (e.button === 0 && e.target.parentNode && e.target.parentNode.parentNode && e.target.parentNode.parentNode.id === 'irff_s-siteinfo_disableitemlist' && e.target.nodeName === 'INPUT') {
  2366. var temp = $ids('siteinfo_disableitem').value.split('\n');
  2367. if (e.target.checked) {
  2368. var chkbox = getElementsByXPath('//input', e.target.parentNode.parentNode.cloneNode(true));
  2369. if (chkbox && !chkbox.some(a => {
  2370. if (!a.checked) return true;
  2371. })) {
  2372. e.target.checked = false;
  2373. return;
  2374. }
  2375. temp.push(e.target.nextSibling.textContent);
  2376. } else {
  2377. temp = temp.filter(a => a !== e.target.nextSibling.textContent);
  2378. }
  2379. temp = temp.filter(a => !/^\s*$/.test(a));
  2380. $ids('siteinfo_disableitem').value = temp.join('\n');
  2381. } else if (e.button === 0) FullFeed.checkRegister();
  2382. }, true);
  2383. $ids('titlebar').addEventListener('dblclick', e => {
  2384. if (e.target.nodeName === 'DIV') {
  2385. $ids('tab').classList.toggle('irff_s-hide');
  2386. $ids('list').classList.toggle('irff_s-hide');
  2387. $ids('titlebar_button').classList.toggle('irff_s-hide');
  2388. }
  2389. }, false);
  2390. $id('reader_pane').addEventListener('scroll', e => {
  2391. var btn = $id('view_style_img'),
  2392. rp = $id('reader_pane'),
  2393. s = 'reader_pane_view_style_',
  2394. eAc, eFl;
  2395. if (st.autopagerize && (rp.classList.contains(`${s}0`) || (btn && btn.hasAttribute('src') && /menu2\.png$/.test(btn.getAttribute('src'))))) {
  2396. eAc = rp.getElementsByClassName('article_current')[0];
  2397. if (eAc) eFl = eAc.getElementsByClassName('irff_loaded')[0];
  2398. if (eFl) FullFeed.checkScroll();
  2399. } else if (rp.classList.contains(`${s}1`) || (btn && btn.hasAttribute('src') && /page-break\.png$/.test(btn.getAttribute('src')))) {
  2400. if (st.autopagerize) FullFeed.checkScroll();
  2401. FullFeed.checkRegister();
  2402. }
  2403. e.stopPropagation();
  2404. }, { passive: true });
  2405. $id('three_way_contents').addEventListener('scroll', e => {
  2406. if (st.autopagerize) {
  2407. FullFeed.checkScroll();
  2408. }
  2409. e.stopPropagation();
  2410. }, { passive: true });
  2411. document.addEventListener('scroll', e => {
  2412. var ad = $id('article_dialog'),
  2413. rp = $id('reader_pane');
  2414. if (st.autopagerize && ad && rp && (rp.classList.contains('reader_pane_view_style_3') || rp.classList.contains('reader_pane_view_style_4'))) {
  2415. if (ad.getElementsByClassName('article_full_contents')[0]) {
  2416. FullFeed.checkScroll();
  2417. e.stopPropagation();
  2418. }
  2419. }
  2420. }, { capture: true, passive: true });
  2421. $id('irff_s').addEventListener('change', e => {
  2422. var id = e.target.id;
  2423. if (!id) return;
  2424. if (/whitelist_r/.test(id)) {
  2425. $ids('autoload_whitelist_feed').classList.toggle('select');
  2426. $ids('autoload_whitelist_article').classList.toggle('select');
  2427. } else if (/blacklist_r/.test(id)) {
  2428. $ids('autoload_blacklist_feed').classList.toggle('select');
  2429. $ids('autoload_blacklist_article').classList.toggle('select');
  2430. } else if (/etc_mode-/.test(id)) toggleSettingsMode();
  2431. }, false);
  2432. st.version = version;
  2433. FullFeed.saveSettings();
  2434. loadTwitterWidgetsScript();
  2435. };
  2436.  
  2437. var loadFailure = function(e) {
  2438. if (!/^input|^textarea/i.test(e.target.tagName) && e.keyCode === 69 && e.altKey && e.ctrlKey && e.shiftKey) {
  2439. exportSettings();
  2440. }
  2441. };
  2442. document.addEventListener('keydown', loadFailure, true);
  2443. initInterval = window.setInterval(() => {
  2444. var tree = $id('tree');
  2445. if (/ino\s?reader/i.test(document.title) && tree && tree.innerHTML) {
  2446. window.clearInterval(initInterval);
  2447. window.setTimeout(() => init(), 1000);
  2448. document.removeEventListener('keydown', loadFailure, true);
  2449. }
  2450. }, 500);
  2451.  
  2452. // == [Utility] =================================
  2453.  
  2454. function removeXSSRisks(htmldoc) {
  2455. var attr = 'allowScriptAccess',
  2456. embed = htmldoc.getElementsByTagName('embed'),
  2457. param = htmldoc.getElementsByTagName('param');
  2458. for (var i1 = 0, j1 = embed.length; i1 < j1; i1++) {
  2459. if (embed[i1] && embed[i1].hasAttribute(attr)) embed[i1].setAttribute(attr, 'never');
  2460. }
  2461. for (var i2 = 0, j2 = param.length; i2 < j2; i2++) {
  2462. if (param[i2] && param[i2].hasAttribute('name') && param[i2].getAttribute('name') === attr) param[i2].setAttribute('value', 'never');
  2463. }
  2464. }
  2465.  
  2466. function searchEntry(htmldoc) {
  2467. var arM = ['hentry', 'xfolkentry', 'autopagerize_page_element'],
  2468. ar1 = ['articlebody', 'articlebox', 'articlemain', 'articlesection', 'articletable', 'articlesbody', 'articlesbox', 'articlessection', 'articlestable', 'blockstory', 'blogbody', 'center', 'entlybody', 'entlytext', 'entrybody', 'entrycontent', 'entrytable', 'entrytext', 'mainarticle', 'maintext', 'maintxt', 'singlecontent', 'storycontent', 'yjmt'],
  2469. ar2 = ['blockleaf', 'boxcontent', 'contentbody', 'contentbox', 'contentinner', 'contenttext', 'contentsbody', 'contentsbox', 'contentsinner', 'contentstext', 'maincontent', 'mainframe', 'middlecontent', 'middlecontainer', 'newsbody', 'postbody', 'postcontent', 'textbody', 'kiji', 'newart'],
  2470. ar3 = ['article', 'blog', 'body', 'column', 'content', 'entry', 'main', 'middle', 'page', 'post', 'section', 'story', 'text', 'entries'],
  2471. s1 = '//*[contains(translate(concat(',
  2472. s2 = '@id, " ", @class',
  2473. s3 = '), "ABCDEFGHIJKLMNOPQRSTUVWXYZ-_ ", "abcdefghijklmnopqrstuvwxyz"), "',
  2474. s4 = '")]',
  2475. nM = arM.length,
  2476. n1 = ar1.length,
  2477. n2 = ar2.length,
  2478. n3 = ar3.length;
  2479. var makeXpath = function(ar, len, sp) {
  2480. var x = [];
  2481. ar.forEach((a, i) => {
  2482. if (sp) x.push(`${s1}" ", ${s2}, " "${s3} ${a} ${s4}`);
  2483. else x.push(s1 + s2 + s3 + a + s4);
  2484. if (len > i + 1) x.push('|');
  2485. });
  2486. return x.join('');
  2487. };
  2488. var xpath = function() {
  2489. var ar = ['date', 'foot', 'head', 'media', 'menu', 'navbar', 'navi', 'side', 'tool', 'widget'],
  2490. s5 = '[not((.|.//*|ancestor-or-self::*)[contains(translate(concat(@id, " ", @class), "ABCDEFGHIJKLMNOPQRSTUVWXYZ-_", "abcdefghijklmnopqrstuvwxyz"), "',
  2491. s6 = '")])]',
  2492. x = ['//*[not(.//head|ancestor-or-self::head)][not(.//link|ancestor-or-self::link)][not(.//style|ancestor-or-self::style)]'];
  2493. ar.forEach(a => x.push(s5 + a + s6));
  2494. return x.join('');
  2495. };
  2496. try {
  2497. var elms = getElementsByXPath(makeXpath(arM, nM, true), htmldoc),
  2498. max = 0,
  2499. data;
  2500. if (!elms) elms = getElementsByXPath(makeXpath(ar1, n1, true), htmldoc);
  2501. if (!elms) elms = getElementsByXPath(makeXpath(ar1, n1, false), htmldoc);
  2502. if (!elms) elms = getElementsByXPath(makeXpath(ar2, n2, true), htmldoc);
  2503. if (!elms) elms = getElementsByXPath(makeXpath(ar2, n2, false), htmldoc);
  2504. if (!elms) elms = getElementsByXPath(makeXpath(ar3, n3, true), htmldoc);
  2505. if (!elms) elms = getElementsByXPath(makeXpath(ar3, n3, false), htmldoc);
  2506. if (!elms) elms = getElementsByXPath(xpath(), htmldoc);
  2507. if (!elms) return null;
  2508. elms.forEach(e => {
  2509. if (typeof e.textContent !== 'string') return;
  2510. var n = e.textContent.replace(/^\s+|\s+$|(?:\r?\n|\r){2,}/g, '').length;
  2511. if (max < n) {
  2512. max = n;
  2513. data = e;
  2514. }
  2515. });
  2516. return (data) ? [data] : null;
  2517. } catch (e) {
  2518. return null;
  2519. }
  2520. }
  2521.  
  2522. function relativeToAbsolutePath(htmldoc, base) {
  2523. var hre = htmldoc.querySelectorAll('*[href]'),
  2524. src = htmldoc.querySelectorAll('*[src]'),
  2525. sty = htmldoc.querySelectorAll('*[style*="url"]'),
  2526. top = /^https?:\/\/[^/]+/.exec(base)[0],
  2527. current = base.replace(/\/[^/]+$/, '/'),
  2528. url, abs;
  2529. for (var i1 = 0, j1 = hre.length; i1 < j1; i1++) {
  2530. url = hre[i1].getAttribute('href').trim();
  2531. abs = '';
  2532. if (url && !/^(?:https?|ftp|file|mailto):/.test(url)) abs = _rel2abs(url, top, current, base);
  2533. if (abs) {
  2534. try {
  2535. hre[i1].href = abs;
  2536. } catch (er1) { console.error(er1); }
  2537. }
  2538. }
  2539. for (var i2 = 0, j2 = src.length; i2 < j2; i2++) {
  2540. url = src[i2].getAttribute('src').trim();
  2541. abs = '';
  2542. if (url && !/^(?:https?|ftp|file|mailto):/.test(url)) abs = _rel2abs(url, top, current, base);
  2543. if (abs) {
  2544. try {
  2545. src[i2].src = abs;
  2546. } catch (er2) { console.error(er2); }
  2547. }
  2548. }
  2549. for (var i3 = 0, j3 = sty.length, m, s; i3 < j3; i3++) {
  2550. s = sty[i3].getAttribute('style').trim();
  2551. m = s.match(/url\s*\([^)]+?\)/g);
  2552. url = /url\s*\([^)]+?\)/.exec(s);
  2553. if (!url) continue;
  2554. url = url.toString();
  2555. url = url.slice(url.indexOf('(') + 1, url.lastIndexOf(')'));
  2556. for (var i4 = 0, j4 = m.length; i4 < j4; i4++) {
  2557. abs = '';
  2558. if (url && !/^(?:https?|ftp|file|mailto):/.test(url)) abs = s.replace(m[i4], `url("${ _rel2abs(url, top, current, base) }")`);
  2559. if (abs) {
  2560. try {
  2561. sty[i3].setAttribute('style', abs);
  2562. } catch (er3) { console.error(er3); }
  2563. }
  2564. }
  2565. }
  2566. }
  2567.  
  2568. function _rel2abs(url, top, current, base) {
  2569. if (/^\/\//.test(url)) return top.slice(0, top.indexOf('//')) + url;
  2570. if (/\/$/.test(current)) current = current.slice(0, -1);
  2571. var uPath = url.split('/'),
  2572. cPath = current.split('/');
  2573. for (var i = 0, j = uPath.length; i < j; i++) {
  2574. if (!uPath[i]) continue;
  2575. if (uPath[i] === '.') {
  2576. uPath.splice(i, 1);
  2577. i -= 1;
  2578. } else if (uPath[i] === '..') {
  2579. uPath.splice(i, 1);
  2580. if (/^\//.test(url)) uPath.splice(i - 1, 1);
  2581. cPath.pop();
  2582. i -= 1;
  2583. }
  2584. }
  2585. current = `${cPath.join('/')}/`;
  2586. url = uPath.join('/');
  2587. if (/^\?/.test(url)) return base.slice(0, base.indexOf('?')) + url;
  2588. if (/^#/.test(url)) return base + url;
  2589. if (/^\//.test(url)) return top + url;
  2590. return current + url;
  2591. }
  2592.  
  2593. function replaceSrcOriginal(htmldoc) {
  2594. var img = htmldoc.getElementsByTagName('img'),
  2595. attr = JSON.parse(`[${st.lazyloadattr}]`);
  2596. for (var i = 0, j = img.length; i < j; i++) {
  2597. for (var k = 0, l = attr.length, s; k < l; k++) {
  2598. s = (img[i].hasAttribute(attr[k])) ? img[i].getAttribute(attr[k]) : null;
  2599. if (s && /^https?:\/\/|^\.?\//.test(s)) img[i].setAttribute('src', s);
  2600. }
  2601. }
  2602. }
  2603.  
  2604. function message(mes, dur, typ) {
  2605. var box = $id('irff_message');
  2606. if (!box) return;
  2607. var dura = (dur < 0) ? 300000 : (!dur) ? 1500 : dur,
  2608. type = typ;
  2609. if (mes) {
  2610. box.innerHTML = mes;
  2611. box.classList.remove('irff_warning');
  2612. if (type) box.classList.add(`irff_${type}`);
  2613. box.classList.remove('irff_hidden');
  2614. window.clearTimeout(messageInterval);
  2615. messageInterval = window.setTimeout(() => {
  2616. box.classList.add('irff_hidden');
  2617. if (type) box.classList.remove(`irff_${type}`);
  2618. box.innerHTML = '';
  2619. }, dura);
  2620. } else {
  2621. box.classList.add('irff_hidden');
  2622. box.innerHTML = '';
  2623. }
  2624. }
  2625.  
  2626. // AutoPagerize (c) id:swdyh
  2627.  
  2628. function createHTMLDocumentByString(str) {
  2629. if (document.documentElement.nodeName !== 'HTML') return new DOMParser().parseFromString(str, 'application/xhtml+xml');
  2630. var html = stripHtmlTag(str),
  2631. htmlDoc;
  2632. try {
  2633. htmlDoc = document.cloneNode(false);
  2634. htmlDoc.appendChild(htmlDoc.importNode(document.documentElement, false));
  2635. } catch (e) {
  2636. htmlDoc = document.implementation.createDocument('http://www.w3.org/1999/xhtml', 'html', null);
  2637. }
  2638. var fragment = createDocumentFragmentByString(html);
  2639. try {
  2640. fragment = htmlDoc.adoptNode(fragment);
  2641. } catch (e) {
  2642. fragment = htmlDoc.importNode(fragment, true);
  2643. }
  2644. htmlDoc.documentElement.appendChild(fragment);
  2645. return htmlDoc;
  2646. }
  2647.  
  2648. // AutoPagerize (c) id:swdyh
  2649.  
  2650. function getElementsByXPath(xpath, node) {
  2651. var ss = getXPathResult(xpath, node, 7),
  2652. data = [];
  2653. for (var i = 0; i < ss.snapshotLength; i++) data.push(ss.snapshotItem(i));
  2654. return (data.length > 0) ? data : null;
  2655. }
  2656.  
  2657. // AutoPagerize (c) id:swdyh
  2658.  
  2659. function getXPathResult(xpath, nod, resultType) {
  2660. var node = nod || document,
  2661. doc = node.ownerDocument || node,
  2662. resolver = doc.createNSResolver(node.documentElement || node),
  2663. defaultNS = null;
  2664. try {
  2665. if (node.nodeType === node.DOCUMENT_NODE) defaultNS = node.documentElement.lookupNamespaceURI(null);
  2666. else defaultNS = node.lookupNamespaceURI(null);
  2667. } catch (e) { console.error(e); }
  2668. if (defaultNS) {
  2669. var defaultPrefix = '__default__',
  2670. defaultResolver = resolver;
  2671. xpath = addDefaultPrefix(xpath, defaultPrefix);
  2672. resolver = function(prefix) {
  2673. return (prefix === defaultPrefix) ? defaultNS : defaultResolver.lookupNamespaceURI(prefix);
  2674. };
  2675. }
  2676. return doc.evaluate(xpath, node, resolver, resultType, null);
  2677. }
  2678.  
  2679. // AutoPagerize (c) id:swdyh
  2680.  
  2681. function addDefaultPrefix(xpath, prefix) {
  2682. var tokenPattern = /([A-Za-z_\u00c0-\ufffd][\w\-.\u00b7-\ufffd]*|\*)\s*(::?|\()?|(".*?"|'.*?'|\d+(?:\.\d*)?|\.(?:\.|\d+)?|[)\]])|(\/\/?|!=|[<>]=?|[([|,=+-])|([@$])/g,
  2683. TERM = 1,
  2684. OPERATOR = 2,
  2685. MODIFIER = 3,
  2686. tokenType = OPERATOR;
  2687. prefix += ':';
  2688.  
  2689. function replacer(token, identifier, suffix, term, operator) {
  2690. if (suffix) tokenType = (suffix === ':' || (suffix === '::' && (identifier === 'attribute' || identifier === 'namespace'))) ? MODIFIER : OPERATOR;
  2691. else if (identifier) {
  2692. if (tokenType === OPERATOR && identifier !== '*') token = prefix + token;
  2693. tokenType = (tokenType === TERM) ? OPERATOR : TERM;
  2694. } else tokenType = (term) ? TERM : (operator) ? OPERATOR : MODIFIER;
  2695. return token;
  2696. }
  2697. return xpath.replace(tokenPattern, replacer);
  2698. }
  2699.  
  2700. // AutoPagerize (c) id:swdyh
  2701.  
  2702. function createDocumentFragmentByString(str) {
  2703. var doc = document.implementation.createHTMLDocument(''),
  2704. range = doc.createRange();
  2705. range.selectNodeContents(doc.body);
  2706. return range.createContextualFragment(str);
  2707. }
  2708.  
  2709. // AutoPagerize (c) id:swdyh
  2710.  
  2711. function stripHtmlTag(str) {
  2712. var chunks = str.split(/(<html(?:[ \t\r\n][^>]*)?>)/);
  2713. if (chunks.length >= 3) chunks.splice(0, 2);
  2714. str = chunks.join('');
  2715. chunks = str.split(/(<\/html[ \t\r\n]*>)/);
  2716. if (chunks.length >= 3) chunks.splice(chunks.length - 2);
  2717. return chunks.join('');
  2718. }
  2719.  
  2720. function pathToURL(url, path) {
  2721. var re = (path.indexOf('/') === 0) ? /^([a-zA-Z]+:\/\/[^/]+)\/.*$/ : /^(.*\/).*$/;
  2722. return url.replace(re, `$1${path}`);
  2723. }
  2724.  
  2725. function contentScriptInjection(source) {
  2726. var script = document.createElement('script');
  2727. if (debugLog) console.log('contentScriptInjection', source);
  2728. if (typeof source === 'function') source = `(${source})();`;
  2729. script.setAttribute('type', 'application/javascript');
  2730. script.textContent = source;
  2731. document.body.appendChild(script);
  2732. document.body.removeChild(script);
  2733. }
  2734.  
  2735. })();