Source Viewer

View Page Source of any Website.

目前為 2020-10-24 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @version 6.7.1.5
  3. // @author wack.3gp
  4. // @copyright 2019+ , wack.3gp (https://greasyfork.org/users/4792)
  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-ND 4.0; http://creativecommons.org/licenses/by-nc-nd/4.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. // @compatible Chrome tested with Tampermonkey
  16. // ==/UserScript==
  17.  
  18. 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;}");
  19.  
  20. // ==Source==
  21. unsafeWindow.viewthesource = function(){
  22. window.location="view-source:"+window.location;
  23. };
  24. // ==============
  25.  
  26. // ==Body==
  27. body = document.body;
  28. if(body !== null) {
  29. div2 = document.createElement("div");
  30. div2.setAttribute('id','viewthesource');
  31. 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>";
  32. body.appendChild(div2);
  33. }
  34. // ==============
  35.  
  36. // ==Hide==
  37. unsafeWindow.hide = function(){
  38. var a = new Date();
  39. a = new Date(a.getTime() +1000*60*60*24*365);
  40. document.cookie = 'sourcefunction=hide; path=/; expires='+a.toGMTString()+';';
  41. console.info('Set "sourcefunction=hide" cookie for '+window.location);
  42. 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;}");
  43. document.getElementById("viewthesource").innerHTML = "<center><img alt='Show' src='http://fs2.directupload.net/images/150909/7tae9l8k.png' onclick='javascript:show()'></center>";
  44. };
  45. if (document.cookie.indexOf("sourcefunction=hide") >= 0) {
  46. 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;}");
  47. document.getElementById("viewthesource").innerHTML = "<center><img alt='Show' src='http://fs2.directupload.net/images/150909/7tae9l8k.png' onclick='javascript:show()'></center>";
  48. }
  49. // ==Show==
  50. unsafeWindow.show = function(){
  51. document.cookie = 'sourcefunction=hide; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT;';
  52. console.warn('Delete "sourcefunction=hide" cookie for '+window.location);
  53. 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;}");
  54. 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>";
  55. };
  56. // ==============