InoReader Full Feed

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

当前为 2017-07-10 提交的版本,查看 最新版本

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