Source Viewer

View Page Source of any Website.

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

  1. // ==UserScript==
  2. // @version 6.7.1.4
  3. // @author wack.3gp
  4. // @copyright 2019+ , wack.3gp
  5. // @description View Page Source of any Website.
  6. // @description:de Schauen Sie sich den Seitenquelltext von jeder belieben Website an.
  7. // @grant GM_addStyle
  8. // @grant unsafeWindow
  9. // @include *://*
  10. // @license CC BY-NC 3.0; http://creativecommons.org/licenses/by-nc/3.0/
  11. // @name Source Viewer
  12. // @name:de Seitenquelltext anzeiger
  13. // @namespace https://greasyfork.org/users/4792
  14. // @supportURL https://greasyfork.org/scripts/4611/feedback
  15. // ==/UserScript==
  16.  
  17. GM_addStyle("#viewthesource{border: solid 1px black;position: fixed;right: 0;left: 0;bottom: 0px;background-color: #9E9E9E;z-index: 9999;height: 33px;width: 130px;margin: auto;}");
  18.  
  19. // ==Source==
  20. unsafeWindow.viewthesource = function(){
  21. window.location="view-source:"+window.location;
  22. };
  23. // ==============
  24.  
  25. // ==Body==
  26. body = document.body;
  27. if(body !== null) {
  28. div2 = document.createElement("div");
  29. div2.setAttribute('id','viewthesource');
  30. div2.innerHTML = "<center><img alt='Hide' src='http://fs2.directupload.net/images/150909/sxcclyoz.png' onclick='javascript:hide()'></center>\n<a href='javascript:viewthesource()' onclick='javascript:viewthesource()'>Click to view source!</a>";
  31. body.appendChild(div2);
  32. }
  33. // ==============
  34.  
  35. // ==Hide==
  36. unsafeWindow.hide = function(){
  37. var a = new Date();
  38. a = new Date(a.getTime() +1000*60*60*24*365);
  39. document.cookie = 'sourcefunction=hide; path=/; expires='+a.toGMTString()+';';
  40. console.info('Set "sourcefunction=hide" cookie for '+window.location);
  41. GM_addStyle("#viewthesource{border: solid 1px black;position: fixed;right: 0;left: 0;bottom: 0px;background-color: #9E9E9E;z-index: 9999;height: 15px;width: 45px;margin: auto;}");
  42. document.getElementById("viewthesource").innerHTML = "<center><img alt='Show' src='http://fs2.directupload.net/images/150909/7tae9l8k.png' onclick='javascript:show()'></center>";
  43. };
  44. if (document.cookie.indexOf("sourcefunction=hide") >= 0) {
  45. GM_addStyle("#viewthesource{border: solid 1px black;position: fixed;right: 0;left: 0;bottom: 0px;background-color: #9E9E9E;z-index: 9999;height: 15px;width: 45px;margin: auto;}");
  46. document.getElementById("viewthesource").innerHTML = "<center><img alt='Show' src='http://fs2.directupload.net/images/150909/7tae9l8k.png' onclick='javascript:show()'></center>";
  47. }
  48. // ==Show==
  49. unsafeWindow.show = function(){
  50. document.cookie = 'sourcefunction=hide; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT;';
  51. console.warn('Delete "sourcefunction=hide" cookie for '+window.location);
  52. GM_addStyle("#viewthesource{border: solid 1px black;position: fixed;right: 0;left: 0;bottom: 0px;background-color: #9E9E9E;z-index: 9999;height: 33px;width: 130px;margin: auto;}");
  53. document.getElementById("viewthesource").innerHTML = "<center><img alt='Hide' src='http://fs2.directupload.net/images/150909/sxcclyoz.png' onclick='javascript:hide()'></center>\n<a href='javascript:viewthesource()' onclick='javascript:viewthesource()'>Click to view source!</a>";
  54. };
  55. // ==============