custom devconsole

dev console that overrides school policies, doesn't have cool stuff like snowlord7's devconsole, but allows you to edit the DOM (if you know what i mean...)

目前为 2019-10-09 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name custom devconsole
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description dev console that overrides school policies, doesn't have cool stuff like snowlord7's devconsole, but allows you to edit the DOM (if you know what i mean...)
  6. // @author twarped
  7. // @match http*://*/*
  8. // @grant none
  9. // ==/UserScript==
  10. var body = `<div style="width:100%;height:10%;top:0px;background:white;border-style:solid;">
  11. <a style="float:left;cursor:pointer;" id="go_console">console</a>
  12. <a style="cursor:pointer;float:right;" id="exit" href="javascript:document.getElementById('devconsole').remove();">X</a>
  13. </div>
  14. <div style="width:5%;height:100%;float:right;right:0px;" id="commands">
  15. <button id="save" style="width:100%;height:10%;top:0px;float:right;" onclick="javascript:document.documentElement.innerHTML = document.getElementById('textarea').value;">save</button>
  16. <button id="load" style="width:100%;height:10%;float:right;bottom:0px;" onclick="javascript:document.getElementById('textarea').value = document.documentElement.innerHTML;">load</button>
  17. </div>
  18. <div id="elements" style="width:100%; height:90%;bottom:0px;">
  19. <textarea id="textarea" style="width:80%;height:90%;float:left;resize:none;white-space: pre;font-size:14px;line-height:1.6;"/>
  20. </div>`;
  21. var devconsole = document.createElement('div');
  22. devconsole.id = "devconsole";
  23. devconsole.style = "position:sticky;width:100%;height:220px;bottom:0px;top:0;background:grey;z-index:2000;";
  24. devconsole.innerHTML = body;
  25. var opendev = document.createElement('button');
  26. opendev.style = "position:fixed;right:0;top:0;z-index:2000;";
  27. opendev.id = "opendev";
  28. opendev.innerHTML = "OPEN DEV";
  29. opendev.addEventListener("click",function(){
  30. document.body.appendChild(devconsole);
  31. document.getElementById('textarea').value = document.documentElement.innerHTML.replace(/<\/\w+>/g, (e) => e + '\r\n');
  32. });
  33. document.body.appendChild(opendev);