InoReader Full Feed

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

当前为 2018-01-08 提交的版本,查看 最新版本

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