Advertisement
Guest User

Untitled

a guest
Sep 4th, 2019
5,844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.60 KB | None | 0 0
  1. <html>
  2.  
  3. <head>
  4. <meta charset="utf-8" />
  5. <title>Texthooker</title>
  6. <style type="text/css">
  7. body {
  8. background-color: #202020;
  9. color: #eeeeee;
  10. font-size: 1.1em;
  11. font-weight: 400;
  12. line-height: 150%;
  13. margin-top: 1%;
  14. margin-left: 1.5%;
  15. margin-right: 10%;
  16. margin-bottom: 20%;
  17. font-family: "IPAGothic", "Sazanami Gothic", "Kochi Gothic", "VL Gothic", "Ume Gothic", Pro W3", "Hiragino Kaku Gothic Pro", "Osaka Mono", "Osaka", "MS Gothic", "Meiryo", "M+ 1m";
  18.  
  19. }
  20.  
  21. .container {
  22. position: fixed;
  23. top: 3px;
  24. right: 5px;
  25. display: inline-block;
  26. }
  27.  
  28. .line_box {
  29. margin-top: 24px;
  30. }
  31.  
  32. .remove_button {
  33. background-color: rgba(25, 25, 25, 0.0);
  34. color: #9d9d9d;
  35. cursor: pointer;
  36. cursor: hand;
  37. display: inline-block;
  38. font-size: .4em;
  39. line-height: 100%;
  40. margin-left: 8px;
  41. margin-bottom: 2px;
  42. padding: 5px;
  43. visibility: hidden;
  44.  
  45. -webkit-touch-callout: none;
  46. -webkit-user-select: none;
  47. -khtml-user-select: none;
  48. -moz-user-select: none;
  49. -ms-user-select: none;
  50. -o-user-select: none;
  51. user-select: none;
  52. }
  53.  
  54. .line_box:hover>.remove_button {
  55. visibility: visible;
  56. }
  57.  
  58. #counter {
  59. background-color: rgba(25, 25, 25, 0.8);
  60. color: #9d9d9d;
  61. font-size: .4em;
  62. line-height: 100%;
  63. float: left;
  64. padding-left: 8px;
  65. padding-right: 8px;
  66. padding-top: 5px;
  67. padding-bottom: 5px;
  68. }
  69. </style>
  70. <!--
  71.  
  72. To change background color or text color, just replace the style values above with the hex values for the colors you want.
  73. If you want the background of the counter to remain semi-transparent, you must use rgb values like above. The last number (where I've put 0.8) is the opacity level (1.0 = completely opaque).
  74. To change font size, just change the em value to what works for you (the standard size is 1, I like it at 1.5).
  75. To change font weight (boldness), just edit the value above. 100 is quite thin, 400 is default, 900 is quite thick. You may want it higher than default for Mincho fonts.
  76. The line-height value changes the spacing between lines.
  77.  
  78. To use the font of your choice, remove the list of fonts above and put the ENGLISH name of your font in quotation marks (some JP font names are in Japanese).
  79. Be sure to leave a semi-colon at the end of the line.
  80. To find the English name of a given font, first install it, then open Firefox.
  81. Go to about:preferences#content in the address bar, then click on the 'Default font' drop-down menu.
  82. The "correct" name of your font will be listed here - just copy that down and paste it up above.
  83.  
  84. Note that if you would like to use your browser default font, replace the font-family line with font-family:""; or delete it altogether.
  85. Your default is probably Gothic - if you want to try out a good Mincho font, try Aozora Mincho at http://www.freejapanesefont.com/aozora-mincho-download/
  86. For various other free Japanese fonts, visit http://www.freejapanesefont.com/
  87. For more font attribute information visit http://www.w3schools.com/css/css_font.asp
  88.  
  89. -->
  90. </head>
  91.  
  92. <body>
  93.  
  94.  
  95.  
  96. <div class="container">
  97.  
  98. <!-- This is the div used for the counter. -->
  99. <div id="counter" title="No. of characters / No. of lines">0 / 0</div>
  100. <!-- End counter div. -->
  101.  
  102. </div>
  103.  
  104.  
  105. <script>
  106. //The text inserter/scroller and the counter begin here.
  107.  
  108. //These are needed later.
  109. let lines = 0
  110. let chars = 0
  111.  
  112. //This function is invoked when a node(line) is inserted.
  113. let callback = function (mutations) {
  114.  
  115. //Confirm that a new line (a <p> tag) was inserted.
  116. //(Rikai also inserts and removes a node (a div).)
  117. mutations.forEach((mutation) => {
  118. if (mutation.target == document.body &&
  119. mutation.type == 'childList' &&
  120. mutation.addedNodes.length >= 1) {
  121. let ptag
  122. mutation.addedNodes.forEach((node) => {
  123. if (node.tagName == 'P') {
  124. ptag = node
  125. }
  126. })
  127. if (!ptag) return
  128. //Found the inserted line.
  129.  
  130. //Wrap the inserted text in a div and append a "remove line" button.
  131. let text = ptag.textContent
  132. ptag.remove()
  133. let div = document.createElement('div')
  134. div.classList.add('line_box')
  135. div.innerHTML = '<span></span><div class="remove_button" onclick="delet(this)">x</div>'
  136. div.getElementsByTagName('span')[0].textContent = text
  137. document.body.appendChild(div)
  138.  
  139. //Update the counter.
  140. let lineLen = text.length
  141. updateCounter(lineLen, 1)
  142.  
  143. //The text-scroller is below.
  144. //I've included it in the "new line" function (we are in it now).
  145. //(That is, it won't run unless a new line was added.)
  146. //Like this it won't autoscroll down every time Rikai is used.
  147.  
  148. var LEEWAY = 200; // Amount of "leeway" pixels before latching onto the bottom.
  149.  
  150. // Some obscene browser shit because making sense is for dweebs
  151. var b = document.body;
  152. var offset = b.scrollHeight - b.offsetHeight;
  153. var scrollPos = (b.scrollTop + offset);
  154. var scrollBottom = (b.scrollHeight - (b.clientHeight + offset));
  155.  
  156. // If we are at the bottom, go to the bottom again.
  157. if (scrollPos >= scrollBottom - LEEWAY) {
  158. window.scrollTo(0, document.body.scrollHeight);
  159. }
  160. }
  161. })
  162. }
  163. // End of new line and scroller script.
  164.  
  165. //Register the above new line callback function.
  166. let observer = new MutationObserver(callback)
  167. let observerOptions = { childList: true, attributes: false }
  168. observer.observe(document.body, observerOptions)
  169.  
  170.  
  171. //Beginning of "remove line" function.
  172.  
  173. function delet(xdiv) {
  174.  
  175. //Get the length of the line being removed.
  176. let line = xdiv.parentNode.getElementsByTagName('span')[0].textContent
  177. let lineLen = line.length
  178.  
  179. //Remove the line.
  180. xdiv.parentNode.remove()
  181.  
  182. //Update the counter.
  183. updateCounter(-lineLen, -1)
  184. }
  185. //End of "remove line" function.
  186.  
  187. //Function to update the char and line counter.
  188. function updateCounter(charDiff, lineDiff) {
  189. chars = chars + charDiff
  190. lines = lines + lineDiff
  191. let charsdisp = chars.toLocaleString()
  192. let linesdisp = lines.toLocaleString()
  193. document.getElementById('counter').textContent = charsdisp + ' / ' + linesdisp
  194. }
  195.  
  196. </script>
  197. </body>
  198.  
  199. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement