Source Viewer

View Page Source of any Website.

当前为 2020-10-30 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @version 6.7.2.0
  3. // @name Source Viewer
  4. // @name:de Seitenquelltext anzeiger
  5. // @description View Page Source of any Website.
  6. // @description:de Schauen Sie sich den Seitenquelltext von jeder beliebigen Website an.
  7. // @author wack.3gp
  8. // @copyright 2019+ , wack.3gp (https://greasyfork.org/users/4792)
  9. // @grant unsafeWindow
  10. // @noframes
  11. // @include *
  12. // @license CC BY-NC-ND 4.0; http://creativecommons.org/licenses/by-nc-nd/4.0/
  13. // @namespace https://greasyfork.org/users/4792
  14. // @supportURL https://greasyfork.org/scripts/4611/feedback
  15. // @compatible Chrome tested with Tampermonkey
  16. // ==/UserScript==
  17.  
  18. unsafeWindow.viewsource = function () {
  19. var source = "<html>";
  20. source += document.getElementsByTagName('html')[0].innerHTML;
  21. source += "</html>";
  22. source = source.replace(/</g, "&lt;").replace(/>/g, "&gt;");
  23. source = "<pre>"+source+"</pre>";
  24. var sourceWindow = window.open();
  25. sourceWindow.document.write(source);
  26. sourceWindow.document.close();
  27. if(window.focus) sourceWindow.focus();
  28. };
  29. // ==============
  30.  
  31. var body = document.body;
  32. if (body !== null) {
  33. var div = document.createElement("div");
  34. div.setAttribute('id', 'viewsource');
  35. div.innerHTML = "<center><button onclick='javascript:viewsource()'>Click to view source!</button></center>";
  36. body.appendChild(div);
  37. document.getElementById("viewsource").style = "position: fixed;right: 0;left: 0;bottom: 0px;margin: auto;";
  38. }
  39. // ==============