InoReader Key Customize

Customize keyboard shortcuts in InoReader. / InoReaderのキーボードショートカットをカスタマイズします。

  1. // ==UserScript==
  2. // @name InoReader Key Customize
  3. // @description Customize keyboard shortcuts in InoReader. / InoReaderのキーボードショートカットをカスタマイズします。
  4. // @description:en Customize keyboard shortcuts in InoReader.
  5. // @description:ja InoReaderのキーボードショートカットをカスタマイズします。
  6. // @id InoReaderKeyCustomize
  7. // @namespace http://userscripts.org/scripts/show/173920
  8. // @homepage https://greasyfork.org/scripts/898-inoreader-key-customize
  9. // @include http://inoreader.com/*
  10. // @include https://inoreader.com/*
  11. // @include http://www.inoreader.com/*
  12. // @include https://www.inoreader.com/*
  13. // @include http://jp.inoreader.com/*
  14. // @include https://jp.inoreader.com/*
  15. // @include http://us.inoreader.com/*
  16. // @include https://us.inoreader.com/*
  17. // @exclude *inoreader.com/stream*
  18. // @exclude *inoreader.com/m/*
  19. // @grant GM_openInTab
  20. // @noframes
  21. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js
  22. // @compatible firefox Firefox93以降ではabout:configを開いて"dom.keyboardevent.init_key_event.enabled"を"true"に変更してください。
  23. // @version 1.81
  24. // ==/UserScript==
  25.  
  26. (function() {
  27. 'use strict';
  28.  
  29. if (!/Ino\s?reader/i.test(document.title)) return;
  30. var gTimeout = 2000,
  31. key = {},
  32. key2 = {},
  33. st = {},
  34. cha = '',
  35. cha2 = '',
  36. anime = false,
  37. iInit;
  38. var $id = function(id) {
  39. return document.getElementById(id);
  40. };
  41. var init = function() {
  42. if (typeof jQuery !== 'function') return;
  43. var localeJa = {
  44. general: [
  45. '設定',
  46. 'キャンセル',
  47. '"g"以外の英数字を登録。(例 "b": Bキーで動作 "B": Shift+Bキーで動作)',
  48. 'スムーズスクロール',
  49. 'スクロール時間 (ミリ秒)',
  50. 'スクロールマージン',
  51. 'インラインフレームをサンドボックス化',
  52. 'フォームの実行を許可',
  53. 'スクリプトの実行を許可',
  54. '前後の記事を選択する処理を軽量化'
  55. ],
  56. tabs: [
  57. 'ナビゲーション',
  58. 'アイテム',
  59. 'ジャンプ',
  60. 'アプリケーション',
  61. 'ビュー',
  62. 'スクロール',
  63. 'その他'
  64. ],
  65. navigation: {
  66. k: '前の記事を開く ( k )',
  67. j: '次の記事を開く ( j )',
  68. p: '前の記事を選択 ( p )',
  69. n: '次の記事を選択 ( n )',
  70. o: '選択した記事を開閉 ( o )',
  71. X: '選択したフォルダを開閉 ( X )',
  72. K: '前のタグ/フィード/フォルダを開く ( K )',
  73. J: '次のタグ/フィード/フォルダを開く ( J )',
  74. P: '前のタグ/フィード/フォルダを選択 ( P )',
  75. N: '次のタグ/フィード/フォルダを選択 ( N )',
  76. O: '選択したタグ/フィード/フォルダを開く ( O )',
  77. D: '選択したタグ/フィード/フォルダを削除 ( D )',
  78. R: '選択したタグ/フィード/フォルダをリネーム ( R )'
  79. },
  80. items: {
  81. v: '記事を新しいタブで開く ( v* )',
  82. b: '記事をバックグラウンドの新しいタブで開く ( b* )',
  83. m: '記事を既読/未読にする ( m )',
  84. A: 'すべての記事を既読にする ( A )',
  85. ctrlM: '上側の記事をすべて既読にする ( Ctrl+m )',
  86. M: '下側の記事をすべて既読にする ( M )',
  87. q: '記事全体をインラインフレームで読み込む ( q )',
  88. w: 'モバイル用コンテンツを読み込む ( w )',
  89. l: '記事に「いいね!」を付ける/外す ( l )',
  90. f: '記事にスターを付ける/外す ( f )',
  91. i: '記事をInstapaperへ送信 ( i )',
  92. x: '記事をOneNoteへ送信 ( x )',
  93. y: '記事をPocketへ送信 ( y )',
  94. z: '記事をEvernoteへ送信 ( z )',
  95. c: '記事にコメント ( c )',
  96. e: '記事をメールで共有 ( e )',
  97. s: '記事を拡散する ( s )',
  98. t: '記事のタグを編集 ( t )'
  99. },
  100. jump: {
  101. gd: '「ダッシュボード」を開く ( g-d )',
  102. ga: '「全ての記事」を開く ( g-a )',
  103. gf: '「お気に入り」を開く ( g-f )',
  104. gw: '「保存したウェブページ」を開く ( g-w )',
  105. gs: '「統計表示」を開く ( g-s )',
  106. gc: '「チャンネル」を開く ( g-c )',
  107. gu: 'フィードを指定して表示 ( g-u )',
  108. gt: 'タグ/フォルダを指定して表示 ( g-t )',
  109. period: 'タグ/フォルダ/フィード/セクションを指定して表示 ( . )'
  110. },
  111. application: {
  112. a: 'フィードを追加 ( a )',
  113. r: '更新 ( r )',
  114. slash: '検索ボックスにフォーカス ( / )',
  115. plus: '文字サイズを大きく ( + )',
  116. minus: '文字サイズを小さく ( - )',
  117. _0: '文字サイズをリセット ( 0 )',
  118. d: 'ツリーの表示/非表示 ( d )',
  119. u: 'ツリーの表示/(記事を最大幅に広げて)非表示 ( u )',
  120. altP: '設定ダイアログを開く ( Alt+p )',
  121. altC: '更新履歴を開く ( Alt+c )',
  122. altI: '講読アイテム/フォルダ/タグの情報を表示 ( Alt+i )',
  123. h: 'ヘルプを開く ( h )'
  124. },
  125. reading: {
  126. _1: 'リストビューへ切替 ( 1 )',
  127. _2: '展開ビューへ切替 ( 2 )',
  128. _3: 'リストビューへ切替 ( 3 )',
  129. _4: 'カードビューへ切替 ( 4 )',
  130. _5: 'マガジンビューへ切替 ( 5 )',
  131. $sortNewest: '記事を新しい順に表示',
  132. $sortOldest: '記事を古い順に表示',
  133. shift1: 'すべての記事を表示 ( Shift+1 )',
  134. shift2: '未読記事のみ表示 ( Shift+2 )',
  135. shift3: 'スター付き記事のみ表示 ( Shift+3 )',
  136. $subscriptionsAll: 'すべての購読アイテムを表示',
  137. $subscriptionsUpdate: '未読の購読アイテムのみ表示',
  138. $subscriptionsDim: '既読の購読アイテムを薄く表示'
  139. },
  140. scroll: {
  141. PageUp: '上に1ページスクロール ( PageUp* )',
  142. PageDown: '下に1ページスクロール ( PageDown* )',
  143. Home: '先頭にスクロール ( Home* )',
  144. End: '末尾にスクロール ( End* )',
  145. Up: '上に1行スクロール ( Up* )',
  146. Down: '下に1行スクロール ( Down* )',
  147. SPACE: '上にスクロール / 前へ移動 ( SPACE* )',
  148. space: '下にスクロール / 次へ移動 ( space* )'
  149. },
  150. etc: {}
  151. };
  152. var localeEn = {
  153. general: [
  154. 'Settings',
  155. 'Cancel',
  156. 'An alphanumeric character except "g". (for example, "b": b key, "B": Shift-b key)',
  157. 'Smooth Scrolling',
  158. 'Scroll duration (msec)',
  159. 'Scroll margin',
  160. 'Sandboxed iframe',
  161. 'Allow Scripts',
  162. 'Allow Forms',
  163. 'Lightweight process for focus previous/next article'
  164. ],
  165. tabs: [
  166. 'Navigation',
  167. 'Items',
  168. 'Jump',
  169. 'Application',
  170. 'Reading',
  171. 'Scroll',
  172. 'Others'
  173. ],
  174. navigation: {
  175. k: 'Previous article ( k )',
  176. j: 'Next article ( j )',
  177. p: 'Focus previous article ( p )',
  178. n: 'Focus next article ( n )',
  179. o: 'Open/Close article ( o )',
  180. X: 'Open/Collapse folder ( X )',
  181. K: 'Previous item ( K )',
  182. J: 'Next item ( J )',
  183. P: 'Focus previous item ( P )',
  184. N: 'Focus next item ( N )',
  185. O: 'Open focused item ( O )',
  186. D: 'Delete folder/feed ( D )',
  187. R: 'Rename folder/feed ( R )'
  188. },
  189. items: {
  190. v: 'Open in new tab ( v* )',
  191. b: 'Open in background tab ( b* )',
  192. m: 'Mark as read/unread ( m )',
  193. A: 'Mark all as read ( A )',
  194. ctrlM: 'Mark above as read ( Ctrl+m )',
  195. M: 'Mark below as read ( M )',
  196. q: 'Embed full article ( q )',
  197. w: 'Load mobilized content ( w )',
  198. l: 'Like ( l )',
  199. f: 'Star article ( f )',
  200. i: 'Send article to Instapaper ( i )',
  201. x: 'Send article to OneNote ( x )',
  202. y: 'Send article to Pocket ( y )',
  203. z: 'Send article to Evernote ( z )',
  204. c: 'Comment ( c )',
  205. e: 'Send via email ( e )',
  206. s: 'Broadcast ( s )',
  207. t: 'Add tags ( t )'
  208. },
  209. jump: {
  210. gd: 'Dashboard ( g-d )',
  211. ga: 'All articles ( g-a )',
  212. gf: 'Favorites ( g-f )',
  213. gw: 'Saved web pages ( g-w )',
  214. gs: 'Statistics ( g-s )',
  215. gc: 'Channels ( g-c )',
  216. gu: 'Go to feed ( g-u )',
  217. gt: 'All to folder/tag ( g-t )',
  218. period: 'Show Jumper ( . )'
  219. },
  220. application: {
  221. a: 'Add subscription ( a )',
  222. r: 'Refresh feed ( r )',
  223. slash: 'Focus Search ( / )',
  224. plus: 'Increase font size ( + )',
  225. minus: 'Decrease font size ( - )',
  226. _0: 'Reset font size ( 0 )',
  227. d: 'Dock/Undock tree ( d )',
  228. u: 'Dock/Undock tree (full width) ( u )',
  229. altP: 'Preferences ( Alt+p )',
  230. altC: 'Changelog ( Alt+c )',
  231. altI: 'Info dialog ( Alt+i )',
  232. h: 'Open help ( h )'
  233. },
  234. reading: {
  235. _1: 'List view ( 1 )',
  236. _2: 'Expanded view ( 2 )',
  237. _3: 'Column view ( 3 )',
  238. _4: 'Card view ( 4 )',
  239. _5: 'Magazine view ( 5 )',
  240. $sortNewest: 'Newest first',
  241. $sortOldest: 'Oldest first',
  242. shift1: 'All articles ( Shift+1 )',
  243. shift2: 'Unread articles ( Shift+2 )',
  244. shift3: 'Starred articles ( Shift+3 )',
  245. $subscriptionsAll: 'Show all subscriptions',
  246. $subscriptionsUpdate: 'Show updated subscriptions',
  247. $subscriptionsDim: 'Dim read subscriptions'
  248. },
  249. scroll: {
  250. PageUp: 'scroll page up ( PageUp* )',
  251. PageDown: 'scroll page down ( PageDown* )',
  252. Home: 'scroll top ( Home* )',
  253. End: 'scroll end ( End* )',
  254. Up: 'scroll line up ( Up* )',
  255. Down: 'scroll line down ( Down* )',
  256. SPACE: 'scroll up / previous article ( SPACE* )',
  257. space: 'scroll down / next article ( space* )'
  258. },
  259. etc: {}
  260. };
  261. var css = '#irkc_setting { color: black; min-width: 20em; padding: 0 0 0.5em 0; position: absolute; top: 38px; left: 38px; z-index: 90100; background: rgba(255, 255, 255, 0.98); 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; }' +
  262. '#irkc_setting fieldset:disabled > label { color: gray; }' +
  263. '#irkc_setting fieldset, #irkc_setting input[type="text"], #irkc_setting input[type="number"], #irkc_setting textarea { color: black; background-color: transparent; }' +
  264. '.irkc_hide { padding: 0 !important; }' +
  265. '.irkc_hide #irkc_btn, .irkc_hide #irkc_desc, .irkc_hide #irkc_tab, .irkc_hide #irkc_form { display: none; }' +
  266. '#irkc_titlebar { background-color: #666666; border-radius: 4px 4px 0 0; padding: 2px 0 0 4px; height: 2em; -moz-user-select: none; -webkit-user-select: none; }' +
  267. '#irkc_title a { font-weight: bold; color: white; text-decoration: none; }' +
  268. '#irkc_title a:hover { color: #FF9; }' +
  269. '#irkc_btn { position: absolute; top: 2px; right: 4px; }' +
  270. '#irkc_desc { padding: 0 0.5em; margin: 0.5em 0 1em 0; }' +
  271. '#irkc_tab { padding: 0 0.5em; margin-top: 1em; }' +
  272. '#irkc_tab span { background-color: #E9E9E9; background-image: -webkit-linear-gradient(#F9F9F9, #E9E9E9); background-image: linear-gradient(#F9F9F9, #E9E9E9); border: 1px solid #999999; padding: 2px 8px; border-radius: 4px 4px 0 0; cursor: pointer; -moz-user-select: none; -webkit-user-select: none; }' +
  273. '#irkc_tab span:hover { background-color: #F3F3F3; }' +
  274. '#irkc_tab .irkc_tab_selected, #irkc_tab .irkc_tab_selected:hover { background-color: #FFFFFF; background-image: none; border-bottom-color: #FFFFFF; }' +
  275. '#irkc_form { padding: 0.5em; border-top: 1px solid #999999; margin-top: 1px; }' +
  276. '#irkc_form input { margin: 2px 6px; padding: 2px 4px; text-align: center; width: 1.2em; vertical-align: inherit; }' +
  277. '#irkc_form input[type="checkbox"] { vertical-align: top; margin: 2px 2px 2px 0; }' +
  278. '#irkc_form fieldset + fieldset { margin: 0.5em auto; }' +
  279. '#irkc_settings-scrollduration { width: 6ex !important; }' +
  280. '#irkc_settings-scrollmargin_page, #irkc_settings-scrollmargin_space { width: 5ex !important; }' +
  281. '#irkc_items, #irkc_jump, #irkc_application, #irkc_scroll, #irkc_etc { display: none; }' +
  282. '.irkc_row { float: left; padding: 0 5px; }' +
  283. '#irkc_ok { margin-right: 0.5em; padding: 0 2em; }' +
  284. '#irkc_cancel { padding: 0 1ex; }' +
  285. '#irkc_ok, #irkc_cancel { font-size: 80%; }';
  286. var link = document.createElement('link');
  287. link.rel = 'stylesheet';
  288. link.href = `data:text/css,${encodeURIComponent(css)}`;
  289. document.getElementsByTagName('head')[0].appendChild(link);
  290. var div = document.createElement('div');
  291. div.id = 'irkc_setting';
  292. div.style.display = 'none';
  293. document.body.appendChild(div);
  294. var loc = (window.navigator.language === 'ja') ? localeJa : localeEn;
  295. var s = `<div id="irkc_titlebar"><div id="irkc_title"><a href="https://greasyfork.org/scripts/898-inoreader-key-customize" target="_blank">InoReader Key Customize${loc.general[0]}</a></div><div id="irkc_btn"><input id="irkc_ok" type="button" value="OK"><input id="irkc_cancel" type="button" value="${loc.general[1]}"></div></div><div id="irkc_desc">${loc.general[2]}</div><div id="irkc_tab">`;
  296. for (let i = 2, j = Object.keys(loc).length; i < j; i++) s += `<span id="irkc_tab_${Object.keys(loc)[i]}">${loc.tabs[i - 2]}</span>`;
  297. s += '</div><div id="irkc_form">';
  298. var addContents = function(id) {
  299. if (id === 'etc') {
  300. s += `<div id="irkc_etc"><fieldset><legend>${loc.general[3]}</legend><label>${loc.general[4]} :<input type="text" maxlength="4" id="irkc_settings-scrollduration"></label></fieldset><fieldset><legend>${loc.general[5]} (px)</legend><label>PageUp / PageDown :<input type="text" maxlength="3" id="irkc_settings-scrollmargin_page"></label><br><label>Space / Shift+Space :<input type="text" maxlength="3" id="irkc_settings-scrollmargin_space"></label></fieldset><fieldset id="irkc_settings-iframe_sandbox_fs"><legend><label><input type="checkbox" id="irkc_settings-iframe_sandbox">${loc.general[6]}</label></legend><label><input type="checkbox" id="irkc_settings-iframe_sandbox_form">${loc.general[7]}</label><br><label><input type="checkbox" id="irkc_settings-iframe_sandbox_script">${loc.general[8]}</label></fieldset><label><input type="checkbox" id="irkc_settings-replace_movearticle">${loc.general[9]}</label></div>`;
  301. } else {
  302. var n1 = 0,
  303. n2 = Object.keys(loc[id]).length - 1,
  304. s1 = '',
  305. s2 = '';
  306. s += `<div id="irkc_${id}"><span class="irkc_row">`;
  307. for (const i in loc[id]) {
  308. if (Object.prototype.hasOwnProperty.call(loc[id], i)) {
  309. if (Math.floor(n2 / 2) >= n1) s1 += `<label><input id="irkc_key-${i}" type="text" maxlength="2">${loc[id][i]}</label><br>`;
  310. else s2 += `<label><input id="irkc_key-${i}" type="text" maxlength="2">${loc[id][i]}</label><br>`;
  311. n1 += 1;
  312. }
  313. }
  314. s += `${s1}</span><span class="irkc_row">${s2}</span></div>`;
  315. }
  316. };
  317. for (let i = 2, j = Object.keys(loc).length; i < j; i++) addContents(Object.keys(loc)[i]);
  318. s += '</div>';
  319. $id('irkc_setting').innerHTML = s;
  320. var addTabEvent = function(id) {
  321. var tab = $id(`irkc_tab_${id}`);
  322. if (id === 'navigation') tab.className = 'irkc_tab_selected';
  323. tab.addEventListener('click', () => {
  324. for (let i = 2, j = Object.keys(loc).length; i < j; i++) {
  325. $id(`irkc_${Object.keys(loc)[i]}`).style.display = 'none';
  326. $id(`irkc_tab_${Object.keys(loc)[i]}`).className = '';
  327. }
  328. $id(`irkc_${id}`).style.display = 'block';
  329. tab.className = 'irkc_tab_selected';
  330. }, false);
  331. };
  332. $id('irkc_settings-iframe_sandbox').addEventListener('click', () => {
  333. if ($id('irkc_settings-iframe_sandbox').checked) $id('irkc_settings-iframe_sandbox_fs').removeAttribute('disabled');
  334. else $id('irkc_settings-iframe_sandbox_fs').setAttribute('disabled', '');
  335. }, false);
  336. for (let i = 2, j = Object.keys(loc).length; i < j; i++) addTabEvent(Object.keys(loc)[i]);
  337. var loadKey = function() {
  338. var e = document.evaluate('id("irkc_form")//input', document, null, 7, null);
  339. for (let i = 0, j = e.snapshotLength; i < j; i++) {
  340. if (e.snapshotItem(i).value) e.snapshotItem(i).value = '';
  341. e.snapshotItem(i).removeAttribute('style');
  342. }
  343. key = JSON.parse(localStorage.getItem('InoReaderKeyCustomize_key')) || {};
  344. key2 = {};
  345. for (let p in key) {
  346. if (Object.prototype.hasOwnProperty.call(key, p)) {
  347. if (p === 'PO' && !$id('irkc_key-K').value && !key.K) {
  348. $id('irkc_key-K').value = key[p];
  349. key.K = key[p];
  350. p = 'K';
  351. } else if (p === 'NO' && !$id('irkc_key-J').value && !key.J) {
  352. $id('irkc_key-J').value = key[p];
  353. key.J = key[p];
  354. p = 'J';
  355. } else if ($id(`irkc_key-${p}`)) $id(`irkc_key-${p}`).value = key[p];
  356. if (/[A-Z]/.test(key[p])) key[p] = `@${key[p]}`;
  357. else key[p] = key[p].toUpperCase();
  358. key2[p] = key[p].replace(/^(@?)!?(.)$/, '$1$2');
  359. }
  360. }
  361. };
  362. var loadSettings = function() {
  363. var notType = function(t, a) {
  364. return (Object.prototype.toString.call(a).slice(8, 11) !== t) ? true : false;
  365. };
  366. st = JSON.parse(localStorage.getItem('InoReaderKeyCustomize_settings')) || {};
  367. if (notType('Num', st.scrollduration) || st.scrollduration > 2000) st.scrollduration = 200;
  368. if (notType('Num', st.scrollmarginpage) || st.scrollmarginpage > 500) st.scrollmarginpage = 20;
  369. if (notType('Num', st.scrollmarginspace) || st.scrollmarginspace > 500) st.scrollmarginspace = 42;
  370. if (notType('Boo', st.iframesandbox)) st.iframesandbox = false;
  371. if (notType('Boo', st.iframesandboxform)) st.iframesandboxform = false;
  372. if (notType('Boo', st.iframesandboxscript)) st.iframesandboxscript = false;
  373. if (notType('Boo', st.replacemovearticle)) st.replacemovearticle = false;
  374. $id('irkc_settings-scrollduration').value = st.scrollduration;
  375. $id('irkc_settings-scrollmargin_page').value = st.scrollmarginpage;
  376. $id('irkc_settings-scrollmargin_space').value = st.scrollmarginspace;
  377. $id('irkc_settings-iframe_sandbox').checked = st.iframesandbox;
  378. $id('irkc_settings-iframe_sandbox_form').checked = st.iframesandboxform;
  379. $id('irkc_settings-iframe_sandbox_script').checked = st.iframesandboxscript;
  380. $id('irkc_settings-replace_movearticle').checked = st.replacemovearticle;
  381. if (st.iframesandbox) $id('irkc_settings-iframe_sandbox_fs').removeAttribute('disabled');
  382. else $id('irkc_settings-iframe_sandbox_fs').setAttribute('disabled', '');
  383. };
  384. $id('irkc_titlebar').addEventListener('dblclick', e => {
  385. if (e.target.nodeName === 'DIV') $id('irkc_setting').classList.toggle('irkc_hide');
  386. }, false);
  387. $id('irkc_ok').addEventListener('click', () => {
  388. $id('irkc_ok').blur();
  389. viewSettings();
  390. var e = document.evaluate('id("irkc_form")/div/span/label/input', document, null, 7, null),
  391. d = {};
  392. for (let n = 0; n < e.snapshotLength; n++) {
  393. if (/[^0-9a-fh-zA-Z!%&]/.test(e.snapshotItem(n).value)) e.snapshotItem(n).value = '';
  394. if (e.snapshotItem(n).value) d[e.snapshotItem(n).id.slice(9)] = e.snapshotItem(n).value;
  395. }
  396. localStorage.setItem('InoReaderKeyCustomize_key', JSON.stringify(d));
  397. var sd = $id('irkc_settings-scrollduration').value;
  398. var smp = $id('irkc_settings-scrollmargin_page').value;
  399. var sms = $id('irkc_settings-scrollmargin_space').value;
  400. if (sd && !isNaN(sd)) {
  401. sd = Number(sd);
  402. st.scrollduration = (sd < 0) ? 0 : (sd > 2000) ? 2000 : sd;
  403. } else st.scrollduration = 200;
  404. if (smp && !isNaN(smp)) {
  405. smp = Number(smp);
  406. st.scrollmarginpage = (smp < 0) ? 0 : (smp > 500) ? 500 : smp;
  407. } else st.scrollmarginpage = 20;
  408. if (sms && !isNaN(sms)) {
  409. sms = Number(sms);
  410. st.scrollmarginspace = (sms < 0) ? 0 : (sms > 500) ? 500 : sms;
  411. } else st.scrollmarginspace = 42;
  412. st.iframesandbox = $id('irkc_settings-iframe_sandbox').checked;
  413. st.iframesandboxform = $id('irkc_settings-iframe_sandbox_form').checked;
  414. st.iframesandboxscript = $id('irkc_settings-iframe_sandbox_script').checked;
  415. st.replacemovearticle = $id('irkc_settings-replace_movearticle').checked;
  416. localStorage.setItem('InoReaderKeyCustomize_settings', JSON.stringify(st));
  417. loadKey();
  418. loadSettings();
  419. resetListener();
  420. }, false);
  421. $id('irkc_cancel').addEventListener('click', () => {
  422. $id('irkc_cancel').blur();
  423. viewSettings();
  424. loadKey();
  425. loadSettings();
  426. resetListener();
  427. }, false);
  428. var menu = $id('sb_rp_settings_menu'),
  429. pqm = $id('preferences_quick_main'),
  430. item = document.createElement('div');
  431. item.id = 'irkc_settingmenu2';
  432. item.innerHTML = `Key Customize ${loc.general[0]}`;
  433. if (menu) {
  434. item.className = 'inno_toolbar_button_menu_item';
  435. var menuList = menu.children;
  436. if (!menuList[menuList.length - 1].id) {
  437. var line = document.createElement('div');
  438. line.className = 'inno_toolbar_button_menu_line';
  439. menu.insertBefore(line, menu.lastChild.nextSibling);
  440. }
  441. menu.insertBefore(item, menu.lastChild.nextSibling);
  442. } else if ($id('quick_options') && pqm) {
  443. item.className = 'quick_options_link';
  444. pqm.insertBefore(item, pqm.lastChild.nextSibling);
  445. }
  446. if ($id('irkc_settingmenu2')) {
  447. $id('irkc_settingmenu2').addEventListener('click', () => {
  448. viewSettings();
  449. }, false);
  450. }
  451. $('.quick_options_link').click(() => resetListener());
  452. document.addEventListener('keydown', keyDown, true);
  453. document.addEventListener('keypress', keyPress, true);
  454. document.addEventListener('keyup', keyUp, true);
  455. loadKey();
  456. loadSettings();
  457. };
  458.  
  459. var resetListener = function() {
  460. document.removeEventListener('keydown', keyDown, true);
  461. document.removeEventListener('keypress', keyPress, true);
  462. document.removeEventListener('keyup', keyUp, true);
  463. document.addEventListener('keydown', keyDown, true);
  464. document.addEventListener('keypress', keyPress, true);
  465. document.addEventListener('keyup', keyUp, true);
  466. };
  467.  
  468. var currentEntryXPath = function() {
  469. if ($id('article_dialog')) {
  470. return 'id("article_dialog")/div[@class="article_full_contents"]';
  471. }
  472. if ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none' && $id('reader_pane').getElementsByClassName('article_current article_current_3way')[0]) {
  473. return 'id("three_way_contents")/div[@class="article_full_contents"][last()]';
  474. }
  475. if ($id('subscriptions_articles')) {
  476. return 'id("subscriptions_articles")/div[contains(concat(" ", normalize-space(@class), " "), " article_current ")]';
  477. }
  478. return 'id("reader_pane")//div[contains(concat(" ", normalize-space(@class), " "), " article_current ")]';
  479. };
  480.  
  481. var viewSettings = function() {
  482. var se = $id('irkc_setting');
  483. if (se) {
  484. if (se.style.display !== 'block') {
  485. $('#irkc_tab_navigation').click();
  486. se.style.display = 'block';
  487. } else {
  488. se.style.display = 'none';
  489. $id('irkc_ok').removeAttribute('disabled');
  490. }
  491. }
  492. };
  493.  
  494. var contentScriptInjection = function(source) {
  495. var script = document.createElement('script');
  496. if (typeof source === 'function') source = `(${source})();`;
  497. script.setAttribute('type', 'application/javascript');
  498. script.textContent = source;
  499. document.body.appendChild(script);
  500. document.body.removeChild(script);
  501. };
  502.  
  503. var keyDown = function(e) {
  504. var set = $id('irkc_setting'),
  505. code = String.fromCharCode(e.keyCode),
  506. kc = (e.shiftKey) ? code : code.toLowerCase();
  507. if (!set) return;
  508. if (e.ctrlKey && e.altKey && e.shiftKey && e.keyCode === 191) resetListener();
  509. else if (e.ctrlKey && e.shiftKey && e.keyCode === 191) viewSettings();
  510. if (set.style.display === 'block') e.stopPropagation();
  511. if ((e.ctrlKey && code !== 'M') || (e.altKey && /^[^CIP]$/.test(code)) || e.metaKey || set.style.display === 'block' || /input|textarea/i.test(e.target.tagName)) return;
  512. if (e.shiftKey) code = `@${code}`;
  513. if (e.keyCode === 32) code = (e.shiftKey) ? '%' : '&';
  514. switch (code) {
  515. case key2.a:
  516. case key2.A:
  517. case key2.ga:
  518. cha = 'A';
  519. break;
  520. case key2.b:
  521. cha = 'B';
  522. break;
  523. case key2.c:
  524. case key2.gc:
  525. case key2.altC:
  526. cha = 'C';
  527. break;
  528. case key2.d:
  529. case key2.D:
  530. case key2.gd:
  531. cha = 'D';
  532. break;
  533. case key2.e:
  534. cha = 'E';
  535. break;
  536. case key2.f:
  537. case key2.gf:
  538. cha = 'F';
  539. break;
  540. case key2.h:
  541. cha = 'H';
  542. break;
  543. case key2.i:
  544. case key2.altI:
  545. cha = 'I';
  546. break;
  547. case key2.j:
  548. case key2.J:
  549. cha = 'J';
  550. break;
  551. case key2.k:
  552. case key2.K:
  553. cha = 'K';
  554. break;
  555. case key2.l:
  556. cha = 'L';
  557. break;
  558. case key2.m:
  559. case key2.M:
  560. case key2.ctrlM:
  561. cha = 'M';
  562. break;
  563. case key2.n:
  564. case key2.N:
  565. cha = 'N';
  566. break;
  567. case key2.o:
  568. case key2.O:
  569. cha = 'O';
  570. break;
  571. case key2.p:
  572. case key2.P:
  573. case key2.altP:
  574. cha = 'P';
  575. break;
  576. case key2.q:
  577. cha = 'Q';
  578. break;
  579. case key2.r:
  580. case key2.R:
  581. cha = 'R';
  582. break;
  583. case key2.s:
  584. case key2.gs:
  585. cha = 'S';
  586. break;
  587. case key2.t:
  588. case key2.gt:
  589. cha = 'T';
  590. break;
  591. case key2.u:
  592. case key2.gu:
  593. cha = 'U';
  594. break;
  595. case key2.v:
  596. cha = 'V';
  597. break;
  598. case key2.w:
  599. case key2.gw:
  600. cha = 'W';
  601. break;
  602. case key2.x:
  603. case key2.X:
  604. cha = 'X';
  605. break;
  606. case key2.y:
  607. cha = 'Y';
  608. break;
  609. case key2.z:
  610. cha = 'Z';
  611. break;
  612. case key2._0:
  613. cha = 48;
  614. break;
  615. case key2._1:
  616. case key2.shift1:
  617. cha = 49;
  618. break;
  619. case key2._2:
  620. case key2.shift2:
  621. cha = 50;
  622. break;
  623. case key2._3:
  624. case key2.shift3:
  625. cha = 51;
  626. break;
  627. case key2._4:
  628. cha = 52;
  629. break;
  630. case key2._5:
  631. cha = 53;
  632. break;
  633. case key2.plus:
  634. cha = 107;
  635. break;
  636. case key2.minus:
  637. cha = 109;
  638. break;
  639. case key2.period:
  640. cha = 190;
  641. break;
  642. case key2.slash:
  643. cha = 191;
  644. break;
  645. case key2.PageUp:
  646. case key2.PageDown:
  647. case key2.Home:
  648. case key2.End:
  649. case key2.Up:
  650. case key2.Down:
  651. case key2.space:
  652. case key2.SPACE:
  653. case key2.$sortNewest:
  654. case key2.$sortOldest:
  655. case key2.$subscriptionsAll:
  656. case key2.$subscriptionsUpdate:
  657. case key2.$subscriptionsDim:
  658. cha = -1;
  659. break;
  660. default:
  661. cha = '';
  662. }
  663. if (/^\d$/.test(kc)) kc = `_${kc}`;
  664. else if (e.keyCode === 32) kc = (e.shiftKey) ? 'SPACE' : 'space';
  665. else if (e.keyCode === 107) kc = 'plus';
  666. else if (e.keyCode === 109) kc = 'minus';
  667. else if (e.keyCode === 190) kc = 'period';
  668. else if (e.keyCode === 191) kc = 'slash';
  669. if (e.altKey && !e.ctrlKey && !e.shiftKey) kc = `alt${(/^_/.test(kc)) ? '' : '_'}${kc}`;
  670. else if (!e.altKey && e.ctrlKey && !e.shiftKey) kc = `ctrl${(/^_/.test(kc)) ? '' : '_'}${kc}`;
  671. else if (!e.altKey && !e.ctrlKey && e.shiftKey && e.keyCode !== 32) kc = `shift${(/^_/.test(kc)) ? '' : '_'}${kc}`;
  672. if (cha || /^!/.test(key[kc])) e.stopPropagation();
  673. };
  674.  
  675. var keyPress = function(e) {
  676. var set = $id('irkc_setting'),
  677. cc = String.fromCharCode(e.charCode);
  678. if (!set) return;
  679. if (/^irkc_key/.test(e.target.id)) {
  680. e.target.value = e.target.value.trim();
  681. if (/^[0-9a-fh-zA-Z%&]/.test(cc)) {
  682. if (/^[^!]/.test(e.target.value)) e.target.value = null;
  683. else if (/^!/.test(e.target.value)) e.target.value = '!';
  684. }
  685. if (e.charCode === 32) e.target.value = (e.shiftKey) ? '%' : '&';
  686. }
  687. if (e.ctrlKey || e.altKey || e.metaKey || set.style.display === 'block' || /input|textarea/i.test(e.target.tagName)) return;
  688. var evt, eCe,
  689. code = cc.toUpperCase(),
  690. rp = $('#reader_pane'),
  691. ad = $('#article_dialog'),
  692. twc = $('#three_way_contents'),
  693. animeOption = {
  694. duration: st.scrollduration,
  695. complete: function() {
  696. anime = false;
  697. }
  698. };
  699. if (/^\d$/.test(cc)) cc = `_${cc}`;
  700. else if (e.charCode === 32) cc = (e.shiftKey) ? 'SPACE' : 'space';
  701. else if (e.charCode === 43) cc = 'plus';
  702. else if (e.charCode === 45) cc = 'minus';
  703. else if (e.charCode === 46) cc = 'period';
  704. else if (e.charCode === 47) cc = 'slash';
  705. if (!cha || cha === '!') return;
  706. if (e.shiftKey) code = `@${code}`;
  707. if (e.charCode === 32) code = (e.shiftKey) ? '%' : '&';
  708. if (code === 'G') {
  709. document.removeEventListener('keypress', keyPress, true);
  710. setTimeout(() => {
  711. document.addEventListener('keypress', keyPress, true);
  712. }, gTimeout);
  713. return;
  714. }
  715. e.stopPropagation();
  716. if (cha && isNaN(cha)) {
  717. if (cha === '%' || cha === '&') cha = 32;
  718. else cha = cha.charCodeAt();
  719. }
  720. cha2 = cha;
  721. evt = document.createEvent('KeyboardEvent');
  722. switch (code) {
  723. case key2.space:
  724. case key2.SPACE:
  725. case key2.PageUp:
  726. case key2.PageDown:
  727. eCe = document.evaluate(currentEntryXPath(), document, null, 9, null).singleNodeValue;
  728. break;
  729. }
  730. switch (code) {
  731. case key2.a:
  732. case key2.c:
  733. case key2.d:
  734. case key2.e:
  735. case key2.f:
  736. case key2.h:
  737. case key2.i:
  738. case key2.l:
  739. case key2.m:
  740. case key2.o:
  741. case key2.q:
  742. case key2.r:
  743. case key2.s:
  744. case key2.t:
  745. case key2.u:
  746. case key2.w:
  747. case key2.x:
  748. case key2.y:
  749. case key2.z:
  750. case key2._0:
  751. case key2._1:
  752. case key2._2:
  753. case key2._3:
  754. case key2._4:
  755. case key2._5:
  756. case key2.plus:
  757. case key2.minus:
  758. case key2.period:
  759. case key2.slash:
  760. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 0, 0, cha, 0);
  761. break;
  762. case key2.A:
  763. case key2.D:
  764. case key2.J:
  765. case key2.K:
  766. case key2.M:
  767. case key2.N:
  768. case key2.O:
  769. case key2.P:
  770. case key2.R:
  771. case key2.X:
  772. case key2.shift1:
  773. case key2.shift2:
  774. case key2.shift3:
  775. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 1, 0, cha, 0);
  776. break;
  777. case key2.altC:
  778. case key2.altI:
  779. case key2.altP:
  780. evt.initKeyEvent('keydown', 1, 1, null, 0, 1, 0, 0, cha, 0);
  781. break;
  782. case key2.ctrlM:
  783. evt.initKeyEvent('keydown', 1, 1, null, 1, 0, 0, 0, cha, 0);
  784. break;
  785. case key2.ga:
  786. case key2.gc:
  787. case key2.gd:
  788. case key2.gf:
  789. case key2.gs:
  790. case key2.gt:
  791. case key2.gu:
  792. case key2.gw:
  793. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 0, 0, 'G'.charCodeAt(), 0);
  794. break;
  795. case key2.b:
  796. var el1 = document.evaluate(`${currentEntryXPath()}//a[starts-with(@id, "aurl_")]`, document, null, 9, null).singleNodeValue;
  797. if (el1 && el1.href && /^(https?|ftp):\/\/.+$/.test(el1.href)) GM_openInTab(el1.href, true);
  798. else {
  799. el1 = document.evaluate(`${currentEntryXPath()}//a[starts-with(@id, "article_title_link_")]`, document, null, 9, null).singleNodeValue;
  800. if (el1 && el1.href && /^(https?|ftp):\/\/.+$/.test(el1.href)) GM_openInTab(el1.href, true);
  801. }
  802. cha = '';
  803. return;
  804. case key2.j:
  805. case key2.n:
  806. if (st.replacemovearticle) {
  807. var eA1 = document.getElementsByClassName('ar'),
  808. eC1 = document.getElementsByClassName('article_current')[0],
  809. eR1 = $id('reader_pane'),
  810. bC1 = true,
  811. aS1, nS1;
  812. aS1 = /reader_pane_view_style_(\d)/.exec(eR1.className);
  813. if (aS1 && aS1.length === 2) nS1 = aS1[1];
  814. if (!nS1) {
  815. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 0, 0, cha, 0);
  816. break;
  817. }
  818. if (!eC1) {
  819. eC1 = eA1[0];
  820. bC1 = false;
  821. }
  822. if (!eC1) return;
  823. var eN = (bC1) ? eC1.nextElementSibling : eC1;
  824. if (eN && !eN.classList.contains('ar')) {
  825. if (eC1 === eA1[eA1.length - 1] || eN.id === 'next_articles') eN = eC1;
  826. else {
  827. for (var in1 = 0, in2 = eA1.length, in3 = false; in1 < in2; in1++) {
  828. if (in3) {
  829. eN = eA1[in1];
  830. break;
  831. }
  832. if (in1 < in2 - 1 && eC1.id === eA1[in1].id) in3 = true;
  833. }
  834. }
  835. }
  836. if (!eN) return;
  837. if (code === key2.j) {
  838. if (eN.id) contentScriptInjection(`toggle_articleview("${eN.id.slice(eN.id.indexOf('_') + 1)}");`);
  839. } else {
  840. var nT1 = eN.offsetTop,
  841. nB1 = nT1 - eR1.scrollTop;
  842. if (nB1 - eR1.offsetHeight + eN.offsetHeight > 0) {
  843. if (nS1 !== '1') eN.scrollIntoView(false);
  844. else eN.scrollIntoView();
  845. } else if (nB1 < 0) {
  846. if (nS1 !== '1') eN.scrollIntoView();
  847. else eN.scrollIntoView(false);
  848. }
  849. if (bC1) {
  850. eC1.classList.remove('article_current');
  851. if (nS1 !== '1') eC1.classList.remove('article_current_collapsed');
  852. }
  853. eN.classList.add('article_current');
  854. if (nS1 !== '1') eN.classList.add('article_current_collapsed');
  855. }
  856. return;
  857. }
  858. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 0, 0, cha, 0);
  859. break;
  860. case key2.k:
  861. case key2.p:
  862. if (st.replacemovearticle) {
  863. var eA2 = document.getElementsByClassName('ar'),
  864. eC2 = document.getElementsByClassName('article_current')[0],
  865. eR2 = $id('reader_pane'),
  866. bC2 = true,
  867. aS2, nS2;
  868. aS2 = /reader_pane_view_style_(\d)/.exec(eR2.className);
  869. if (aS2 && aS2.length === 2) nS2 = aS2[1];
  870. if (!nS2) {
  871. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 0, 0, cha, 0);
  872. break;
  873. }
  874. if (!eC2) {
  875. eC2 = eA2[0];
  876. bC2 = false;
  877. }
  878. if (!eC2) return;
  879. var eP = (bC2) ? eC2.previousElementSibling : eC2;
  880. if (eP && !eP.classList.contains('ar')) {
  881. if (eC2 === eA2[0]) eP = eC2;
  882. else {
  883. for (var ip1 = eA2.length - 1, ip2 = false; ip1 > 0; ip1--) {
  884. if (ip2) {
  885. eP = eA2[ip1];
  886. break;
  887. }
  888. if (ip1 > 0 && eC2.id === eA2[ip1].id) ip2 = true;
  889. }
  890. }
  891. }
  892. if (!eP) return;
  893. if (code === key2.k) {
  894. if (eP.id) contentScriptInjection(`toggle_articleview("${eP.id.slice(eP.id.indexOf('_') + 1)}");`);
  895. } else {
  896. var nT2 = eP.offsetTop,
  897. nB2 = nT2 - eR2.scrollTop;
  898. if (nB2 - eR2.offsetHeight + eP.offsetHeight > 0) eP.scrollIntoView(false);
  899. else if (nB2 < 0) eP.scrollIntoView();
  900. if (bC2) {
  901. eC2.classList.remove('article_current');
  902. if (nS2 !== '1') eC2.classList.remove('article_current_collapsed');
  903. }
  904. eP.classList.add('article_current');
  905. if (nS2 !== '1') eP.classList.add('article_current_collapsed');
  906. }
  907. return;
  908. }
  909. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 0, 0, cha, 0);
  910. break;
  911. case key2.v:
  912. var el2 = document.evaluate(`${currentEntryXPath()}//a[starts-with(@id, "aurl_")]`, document, null, 9, null).singleNodeValue;
  913. if (el2 && el2.href && /^(https?|ftp):\/\/.+$/.test(el2.href)) GM_openInTab(el2.href);
  914. else {
  915. el2 = document.evaluate(`${currentEntryXPath()}//a[starts-with(@id, "article_title_link_")]`, document, null, 9, null).singleNodeValue;
  916. if (el2 && el2.href && /^(https?|ftp):\/\/.+$/.test(el2.href)) GM_openInTab(el2.href);
  917. }
  918. cha = '';
  919. return;
  920. case key2.space:
  921. if ($id('subscriptions_articles') && $id('subscriptions_articles').innerHTML === '') {
  922. cha = '';
  923. return;
  924. }
  925. if (eCe) {
  926. var bottom = ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none' ? twc.height() : $id('article_dialog') ? ad.height() + 70 : rp.height()) - ($(eCe).position().top + $(eCe).height());
  927. if (bottom > 0) {
  928. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 0, 0, ' '.charCodeAt(), 0);
  929. break;
  930. }
  931. } else {
  932. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 0, 0, ' '.charCodeAt(), 0);
  933. break;
  934. }
  935. if (!anime) {
  936. anime = true;
  937. if ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none') {
  938. twc.animate({
  939. scrollTop: (twc.height() + $id('three_way_contents').scrollTop - ((st.scrollmarginspace + 100 > twc.height()) ? twc.height() - 100 : st.scrollmarginspace))
  940. }, animeOption);
  941. } else if ($id('article_dialog')) {
  942. ad.animate({
  943. scrollTop: (ad.height() + $id('article_dialog').scrollTop - ((st.scrollmarginspace + 100 > ad.height()) ? ad.height() - 100 : st.scrollmarginspace))
  944. }, animeOption);
  945. } else {
  946. rp.animate({
  947. scrollTop: (rp.height() + $id('reader_pane').scrollTop - ((st.scrollmarginspace + 100 > rp.height()) ? rp.height() - 100 : st.scrollmarginspace))
  948. }, animeOption);
  949. }
  950. }
  951. cha = '';
  952. return;
  953. case key2.SPACE:
  954. if ($id('subscriptions_articles') && $id('subscriptions_articles').innerHTML === '') {
  955. cha = '';
  956. return;
  957. }
  958. if (document.evaluate('id("reader_pane")/div[@class="reader_pane_message"]', document, null, 9, null).singleNodeValue || document.evaluate('id("subscriptions_articles")/div[@class="no_unread"]', document, null, 9, null).singleNodeValue) {
  959. var eSel2 = document.evaluate('id("tree_pane")//span[contains(concat(" ", normalize-space(@class), " "), " selected ")]', document, null, 9, null).singleNodeValue;
  960. if (eSel2 && eSel2.id && eSel2.id !== 'link_all_items') {
  961. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 1, 0, 'K'.charCodeAt(), 0);
  962. break;
  963. }
  964. }
  965. if (eCe) {
  966. var top = $(eCe).position().top - ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none' ? twc.position().top : $id('article_dialog') ? ad.position().top : rp.position().top);
  967. if (top >= 0) {
  968. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 1, 0, ' '.charCodeAt(), 0);
  969. break;
  970. }
  971. } else {
  972. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 1, 0, ' '.charCodeAt(), 0);
  973. break;
  974. }
  975. if (!anime) {
  976. anime = true;
  977. if ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none') {
  978. twc.animate({
  979. scrollTop: ($id('three_way_contents').scrollTop - twc.height() + ((st.scrollmarginspace + 100 > twc.height()) ? twc.height() - 100 : st.scrollmarginspace))
  980. }, animeOption);
  981. } else if ($id('article_dialog')) {
  982. ad.animate({
  983. scrollTop: ($id('article_dialog').scrollTop - ad.height() + ((st.scrollmarginspace + 100 > ad.height()) ? ad.height() - 100 : st.scrollmarginspace))
  984. }, animeOption);
  985. } else {
  986. rp.animate({
  987. scrollTop: ($id('reader_pane').scrollTop - rp.height() + ((st.scrollmarginspace + 100 > rp.height()) ? rp.height() - 100 : st.scrollmarginspace))
  988. }, animeOption);
  989. }
  990. }
  991. cha = '';
  992. return;
  993. case key2.PageUp:
  994. if (!anime) {
  995. anime = true;
  996. if ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none') {
  997. twc.animate({
  998. scrollTop: ($id('three_way_contents').scrollTop - twc.height() + ((st.scrollmarginpage + 100 > twc.height()) ? twc.height() - 100 : st.scrollmarginpage))
  999. }, animeOption);
  1000. } else if ($id('article_dialog')) {
  1001. ad.animate({
  1002. scrollTop: ($id('article_dialog').scrollTop - ad.height() + ((st.scrollmarginpage + 100 > ad.height()) ? ad.height() - 100 : st.scrollmarginpage))
  1003. }, animeOption);
  1004. } else {
  1005. rp.animate({
  1006. scrollTop: ($id('reader_pane').scrollTop - rp.height() + ((st.scrollmarginpage + 100 > rp.height()) ? rp.height() - 100 : st.scrollmarginpage))
  1007. }, animeOption);
  1008. }
  1009. }
  1010. cha = '';
  1011. return;
  1012. case key2.PageDown:
  1013. if (!anime) {
  1014. anime = true;
  1015. if ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none') {
  1016. twc.animate({
  1017. scrollTop: (twc.height() + $id('three_way_contents').scrollTop - ((st.scrollmarginpage + 100 > twc.height()) ? twc.height() - 100 : st.scrollmarginpage))
  1018. }, animeOption);
  1019. } else if ($id('article_dialog')) {
  1020. ad.animate({
  1021. scrollTop: (ad.height() + $id('article_dialog').scrollTop - ((st.scrollmarginpage + 100 > ad.height()) ? ad.height() - 100 : st.scrollmarginpage))
  1022. }, animeOption);
  1023. } else {
  1024. rp.animate({
  1025. scrollTop: (rp.height() + $id('reader_pane').scrollTop - ((st.scrollmarginpage + 100 > rp.height()) ? rp.height() - 100 : st.scrollmarginpage))
  1026. }, animeOption);
  1027. }
  1028. }
  1029. cha = '';
  1030. return;
  1031. case key2.Home:
  1032. if (!anime) {
  1033. anime = true;
  1034. if ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none') {
  1035. twc.animate({
  1036. scrollTop: 0
  1037. }, animeOption);
  1038. } else if ($id('article_dialog')) {
  1039. ad.animate({
  1040. scrollTop: 0
  1041. }, animeOption);
  1042. } else {
  1043. rp.animate({
  1044. scrollTop: 0
  1045. }, animeOption);
  1046. }
  1047. }
  1048. cha = '';
  1049. return;
  1050. case key2.End:
  1051. if (!anime) {
  1052. anime = true;
  1053. if ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none') {
  1054. twc.animate({
  1055. scrollTop: ($id('three_way_contents').scrollHeight)
  1056. }, animeOption);
  1057. } else if ($id('article_dialog')) {
  1058. ad.animate({
  1059. scrollTop: ($id('article_dialog').scrollHeight)
  1060. }, animeOption);
  1061. } else {
  1062. rp.animate({
  1063. scrollTop: ($id('reader_pane').scrollHeight)
  1064. }, animeOption);
  1065. }
  1066. }
  1067. cha = '';
  1068. return;
  1069. case key2.Up:
  1070. if (!anime) {
  1071. anime = true;
  1072. if ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none') {
  1073. twc.animate({
  1074. scrollTop: ($id('three_way_contents').scrollTop - 42)
  1075. }, animeOption);
  1076. } else if ($id('article_dialog')) {
  1077. ad.animate({
  1078. scrollTop: ($id('article_dialog').scrollTop - 42)
  1079. }, animeOption);
  1080. } else {
  1081. rp.animate({
  1082. scrollTop: ($id('reader_pane').scrollTop - 42)
  1083. }, animeOption);
  1084. }
  1085. }
  1086. cha = '';
  1087. return;
  1088. case key2.Down:
  1089. if (!anime) {
  1090. anime = true;
  1091. if ($id('three_way_contents') && $id('three_way_contents').style.display !== 'none') {
  1092. twc.animate({
  1093. scrollTop: ($id('three_way_contents').scrollTop + 42)
  1094. }, animeOption);
  1095. } else if ($id('article_dialog')) {
  1096. ad.animate({
  1097. scrollTop: ($id('article_dialog').scrollTop + 42)
  1098. }, animeOption);
  1099. } else {
  1100. rp.animate({
  1101. scrollTop: ($id('reader_pane').scrollTop + 42)
  1102. }, animeOption);
  1103. }
  1104. }
  1105. cha = '';
  1106. return;
  1107. case key2.$sortNewest:
  1108. var eNew1 = $('#sb_rp_view_options_menu > .inno_toolbar_button_menu_item'),
  1109. eNew2 = $('#sb_rp_section_options_menu > div'),
  1110. n1;
  1111. for (var i1 = 0, j1 = eNew2.length; i1 < j1; i1++) {
  1112. if (/heading$/.test(eNew2[i1].className)) {
  1113. n1 = i1;
  1114. break;
  1115. }
  1116. }
  1117. if (eNew1[9] && !eNew1[9].classList.contains('inno_toolbar_button_menu_item_disabled')) eNew1[9].click();
  1118. else if (eNew2[n1 + 2]) eNew2[n1 + 2].click();
  1119. cha = '';
  1120. return;
  1121. case key2.$sortOldest:
  1122. var eOld1 = $('#sb_rp_view_options_menu > .inno_toolbar_button_menu_item'),
  1123. eOld2 = $('#sb_rp_section_options_menu > div'),
  1124. n2;
  1125. for (var i2 = 0, j2 = eOld2.length; i2 < j2; i2++) {
  1126. if (/heading$/.test(eOld2[i2].className)) {
  1127. n2 = i2;
  1128. break;
  1129. }
  1130. }
  1131. if (eOld1[10] && !eOld1[10].classList.contains('inno_toolbar_button_menu_item_disabled')) eOld1[10].click();
  1132. else if (eOld2[n2 + 3]) eOld2[n2 + 3].click();
  1133. cha = '';
  1134. return;
  1135. case key2.$subscriptionsAll:
  1136. $('#subscriptions_radio_all').click();
  1137. cha = '';
  1138. return;
  1139. case key2.$subscriptionsUpdate:
  1140. $('#subscriptions_radio_updated').click();
  1141. cha = '';
  1142. return;
  1143. case key2.$subscriptionsDim:
  1144. $('#subscriptions_radio_dim').click();
  1145. cha = '';
  1146. return;
  1147. default:
  1148. cha = '';
  1149. return;
  1150. }
  1151. document.dispatchEvent(evt);
  1152. switch (code) {
  1153. case key2.q:
  1154. var el5 = document.evaluate(currentEntryXPath(), document, null, 9, null).singleNodeValue,
  1155. itemId = (el5 && el5.id) ? el5.id.slice(el5.id.lastIndexOf('_') + 1) : '';
  1156. if (itemId && $id(`iframe_embed_${itemId}`)) {
  1157. var att = [];
  1158. if (st.iframesandbox) {
  1159. if (st.iframesandboxform) att.push('allow-forms');
  1160. if (st.iframesandboxscript) att.push('allow-scripts');
  1161. $id(`iframe_embed_${itemId}`).setAttribute('sandbox', att.join(' '));
  1162. }
  1163. }
  1164. return;
  1165. case key2.ga:
  1166. case key2.gc:
  1167. case key2.gd:
  1168. case key2.gf:
  1169. case key2.gs:
  1170. case key2.gt:
  1171. case key2.gu:
  1172. case key2.gw:
  1173. evt.initKeyEvent('keydown', 1, 1, null, 0, 0, 0, 0, cha, 0);
  1174. break;
  1175. default:
  1176. cha = '';
  1177. return;
  1178. }
  1179. document.dispatchEvent(evt);
  1180. cha = '';
  1181. };
  1182.  
  1183. var keyUp = function(e) {
  1184. if (/^irkc_key/.test(e.target.id)) {
  1185. e.target.value = e.target.value.trim();
  1186. if (e.target.value.length === 2) {
  1187. e.target.value = e.target.value.replace(/^[^!](.)$/, '$1');
  1188. if (e.target.value === '!!') e.target.value = '!';
  1189. }
  1190. if (/[^0-9a-fh-zA-Z!%&]/.test(e.target.value)) e.target.value = null;
  1191. else if (e.target.value === '!') e.target.style.backgroundColor = null;
  1192. var el = document.evaluate('id("irkc_form")/div/span/label/input', document, null, 7, null),
  1193. key3 = [],
  1194. duplicate = false,
  1195. check = function(a, b, c) {
  1196. var i = 0;
  1197. if (a.some(d => {
  1198. if (d === b) i += 1;
  1199. if (i > 1) return true;
  1200. })) {
  1201. c.style.backgroundColor = '#FFFF66';
  1202. duplicate = true;
  1203. } else c.style.backgroundColor = null;
  1204. };
  1205. for (let n = 0, l = el.snapshotLength, v; n < l; n++) {
  1206. v = el.snapshotItem(n).value;
  1207. if (/[0-9a-fh-zA-Z%&!]/.test(v) && v !== '!') key3.push(v);
  1208. }
  1209. for (let n = 0, l = el.snapshotLength, s, v; n < l; n++) {
  1210. s = el.snapshotItem(n);
  1211. v = s.value;
  1212. if (/[^0-9a-fh-zA-Z%&!]/.test(v)) {
  1213. s.style.backgroundColor = null;
  1214. continue;
  1215. }
  1216. check(key3, v, s);
  1217. }
  1218. if (duplicate) $id('irkc_ok').setAttribute('disabled', '');
  1219. else $id('irkc_ok').removeAttribute('disabled');
  1220. } else if (cha2) {
  1221. e.stopPropagation();
  1222. cha2 = '';
  1223. }
  1224. };
  1225.  
  1226. iInit = window.setInterval(() => {
  1227. var tree = $id('tree');
  1228. if (tree && tree.innerHTML) {
  1229. window.clearInterval(iInit);
  1230. window.setTimeout(() => init(), 1000);
  1231. }
  1232. }, 500);
  1233.  
  1234. })();