InoReader Full Feed

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

当前为 2014-09-12 提交的版本,查看 最新版本

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