InoReader Full Feed

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

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

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