InoReader embed current article

restores the recently-removed (jan 29, 2020 (v13)) functionality to embed the full article page using the q shortcut-key

  1. // ==UserScript==
  2. // @name InoReader embed current article
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description restores the recently-removed (jan 29, 2020 (v13)) functionality to embed the full article page using the q shortcut-key
  6. // @author You
  7. // @match https://www.inoreader.com/*
  8. // @grant none
  9. // ==/UserScript==
  10.  
  11. const injectStyle = () => {
  12. const style = `
  13. .overlayContainer {
  14. width: 100vw;
  15. height: 100vh;
  16. background-color: rgba(0,0,0,0);
  17. position: absolute;
  18. cursor: pointer;
  19. z-index: 99999;
  20. }
  21.  
  22. .embedOverlay {
  23. position: absolute;
  24. z-index: 999999;
  25. background-color: #484848;
  26. width: 90%;
  27. height: 95%;
  28. top: -100%;
  29. left: 5%;
  30. box-shadow: black 0px 0px 20px;
  31. -webkit-animation: slide 0.5s forwards;
  32. animation: slide 0.5s forwards;
  33. }
  34.  
  35. @-webkit-keyframes slide {
  36. 100% { top: 2.5%; }
  37. }
  38.  
  39. @keyframes slide {
  40. 100% { top: 2.5%; }
  41. }
  42.  
  43. .closeControl {
  44. position: absolute;
  45. z-index: 9999999;
  46. cursor: pointer;
  47. right: 30px;
  48. top: 13px;
  49. font-size: 30px;
  50. background-color: white;
  51. border: 1px solid black;
  52. padding: 0 5px;
  53. box-shadow: black 0 0 3px;
  54. }
  55.  
  56. .articleEmbed {
  57. width: 100%;
  58. height: calc(100% - 25px);
  59. height: 100%;
  60. }
  61. `;
  62. const injectedStyle = document.createElement(`style`);
  63. injectedStyle.innerHTML = style;
  64. document.body.appendChild(injectedStyle);
  65. };
  66.  
  67. const hideOverlay = () => {
  68. document.body.removeChild(document.querySelector(`.overlayContainer`));
  69. }
  70.  
  71. const showOverlay = () => {
  72. let selectedArticle;
  73. document.querySelectorAll(`.article_current a`).forEach(a => {
  74. if (!selectedArticle && a.href.startsWith(`http`)) {
  75. selectedArticle = a;
  76. }
  77. });
  78. if (!selectedArticle) {
  79. alert(`Cannot open embed article, because there is no active article selected`);
  80. return;
  81. }
  82.  
  83. const overlayContainerElement = document.createElement(`div`);
  84. overlayContainerElement.className = `overlayContainer`;
  85. overlayContainerElement.onclick = hideOverlay;
  86.  
  87. const overlayElement = document.createElement(`div`);
  88. overlayElement.className = `embedOverlay`;
  89.  
  90. const closeElement = document.createElement(`div`);
  91. closeElement.className = `closeControl`;
  92. closeElement.onclick = (e) => { e.stopPropagation(); hideOverlay(); };
  93. closeElement.innerText = `⨯`;
  94.  
  95. const iframeElement = document.createElement(`iframe`);
  96. iframeElement.className = `articleEmbed`;
  97. iframeElement.src = selectedArticle.href.replace(`http:`, `https:`);
  98.  
  99. overlayElement.appendChild(closeElement);
  100. overlayElement.appendChild(iframeElement);
  101. overlayContainerElement.appendChild(overlayElement);
  102.  
  103. document.body.insertBefore(overlayContainerElement, document.body.childNodes[0]);
  104. }
  105.  
  106. const checkKey = (e) => {
  107. if (document.activeElement.tagName == 'TEXTAREA') {
  108. return;
  109. }
  110. if (event.keyCode == 81 && !event.ctrlKey && !event.shiftKey) { // q
  111. if (!document.querySelector(`.overlayContainer`)) {
  112. showOverlay();
  113. } else {
  114. hideOverlay();
  115. }
  116. }
  117. }
  118.  
  119. const init = () => {
  120. injectStyle();
  121. document.addEventListener("keydown", checkKey);
  122. };
  123.  
  124. init();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址