InoReader Full Feed

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

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

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