InoReader Full Feed

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

当前为 2014-10-13 提交的版本,查看 最新版本

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