Guest User

このブックマークレット使うとコンソール出せます

a guest
Mar 19th, 2023
2,084
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.63 KB | None | 0 0
  1. (function(){
  2. const old = document.getElementById('console');
  3. if(old){
  4. old.parentElement.removeChild(old);
  5. window.console = window._console;
  6. }
  7. const setStyle = function(){
  8. const s = document.createElement('style');
  9. s.innerHTML = `
  10. /* The console container element */
  11. #console {
  12. position: absolute;
  13. width: 330px;
  14. height: 240px;
  15. background-color:black;
  16. }
  17. /* The inner console element. */
  18. .jqconsole {
  19. padding: 10px;
  20. }
  21. /* The cursor. */
  22. .jqconsole-cursor {
  23. background-color: gray;
  24. }
  25. /* The cursor color when the console looses focus. */
  26. .jqconsole-blurred .jqconsole-cursor {
  27. background-color: #666;
  28. }
  29. /* The current prompt text color */
  30. .jqconsole-prompt {
  31. color: #0d0;
  32. }
  33. /* The command history */
  34. .jqconsole-old-prompt {
  35. color: #0b0;
  36. font-weight: normal;
  37. }
  38. /* The text color when in input mode. */
  39. .jqconsole-input {
  40. color: #dd0;
  41. }
  42. /* Previously entered input. */
  43. .jqconsole-old-input {
  44. color: #bb0;
  45. font-weight: normal;
  46. }
  47. /* The text color of the output. */
  48. .jqconsole-output {
  49. color: white;
  50. }
  51. /* The text color of the output. */
  52. .jqconsole-warning {
  53. color: yellow;
  54. }
  55. /* The text color of the output. */
  56. .jqconsole-error {
  57. color: red;
  58. }
  59. /* The text color of the output. */
  60. .jqconsole-info {
  61. color: blue;
  62. }
  63. /* The text color of the output. */
  64. .jqconsole-return {
  65. color: gray;
  66. }
  67. `;
  68. document.head.appendChild(s);
  69. };
  70. setStyle();
  71.  
  72. const loadScript = function(src, cb){
  73. const s = document.createElement('script');
  74. document.head.appendChild(s);
  75. s.onload = cb;
  76. s.src = src;
  77. };
  78. const loadStyle = function(src, cb){
  79. const s = document.createElement('link');
  80. document.head.appendChild(s);
  81. s.onload = cb;
  82. s.href = src;
  83. s.rel = 'stylesheet';
  84. };
  85.  
  86. const initConsole = function(){
  87. var d = document.createElement('div');
  88. d.id = 'console';
  89. document.body.appendChild(d);
  90. $('#console').draggable();
  91. $('#console').resizable();
  92. var jqconsole = $('#console').jqconsole('', '');
  93.  
  94. window._console = window.console;
  95. const writeString = {
  96. log(string){
  97. jqconsole.Write(string + '\n', 'jqconsole-output');
  98. window._console.log(string);
  99. },
  100. warn(string){
  101. jqconsole.Write(string + '\n', 'jqconsole-warning');
  102. window._console.warn(string);
  103. },
  104. error(string){
  105. jqconsole.Write(string + '\n', 'jqconsole-error');
  106. window._console.error(string);
  107. },
  108. info(string){
  109. jqconsole.Write(string + '\n', 'jqconsole-info');
  110. window._console.info(string);
  111. },
  112. isJqConsole: true
  113. };
  114. if(!window.console.isJqConsole){
  115. window.console = writeString;
  116. }
  117.  
  118. jqconsole.RegisterShortcut('A', function() {
  119. jqconsole.MoveToStart();
  120. });
  121. jqconsole.RegisterShortcut('E', function() {
  122. jqconsole.MoveToEnd();
  123. });
  124. var startPrompt = function(){
  125. jqconsole.RegisterMatching('(', ')', 'parents');
  126. const prompt = '> ';
  127. jqconsole.Write(prompt, 'jqconsole-prompt');
  128. const processInput = function(input){
  129. try{
  130. const result = eval(input);
  131. jqconsole.Write(result + '\n', 'jqconsole-return');
  132. }catch(err){
  133. console.log(err);
  134. jqconsole.Write('ERROR: ' + err.message + '\n', 'jqconsole-error');
  135. }
  136. startPrompt();
  137. };
  138. jqconsole.Prompt(true, processInput);
  139. };
  140. startPrompt();
  141. };
  142.  
  143. const jquiCss = '//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css';
  144. const jq = '//jscl-project.github.io/jquery.js';
  145. const jqui = '//code.jquery.com/ui/1.12.1/jquery-ui.js';
  146. const jqconsole = '//jscl-project.github.io/jqconsole.min.js';
  147. loadStyle(jquiCss, function(){
  148. loadScript(jq, function(){
  149. loadScript(jqui, function(){
  150. loadScript(jqconsole, function(){
  151. initConsole();
  152. });
  153. });
  154. });
  155. });
  156. })();
Advertisement
Add Comment
Please, Sign In to add comment