Source Viewer

View Source Code of any homepage

当前为 2015-09-10 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Source Viewer
  3. // @namespace http://scriptz.de.to/
  4. // @description View Source Code of any homepage
  5. // @include http://*/*
  6. // @include https://*/*
  7. // @version 6.4
  8. // @icon http://www.chip.de/ii/8/8/3/8/0/6/0/99e7dc2dba159b09.jpg
  9. // @icon64 http://www.chip.de/ii/8/8/3/8/0/6/0/99e7dc2dba159b09.jpg
  10. // @author Scriptz
  11. // @grant GM_addStyle
  12. // @copyright 2013+ , Scriptz
  13. // ==/UserScript==
  14.  
  15. 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;}")
  16.  
  17. // ==Profile==
  18. unsafeWindow.viewthesource = function(){
  19. window.location="view-source:"+window.location
  20. }
  21. // ==============
  22.  
  23. // ==Body==
  24. body = document.body;
  25. if(body != null) {
  26. div2 = document.createElement("div");
  27. div2.setAttribute('id','viewthesource');
  28. 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> "
  29. body.appendChild(div2);
  30. }
  31. // ==============
  32.  
  33. // ==Hide/Show==
  34. unsafeWindow.hide = function(){
  35. var a = new Date();
  36. a = new Date(a.getTime() +1000*60*60*24*365);
  37. document.cookie = 'sourcefunction=hide; path=/; expires='+a.toGMTString()+';';
  38. }
  39. if (document.cookie.indexOf("sourcefunction=hide") >= 0) {
  40. 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;}")
  41. document.getElementById("viewthesource").innerHTML = "<center><img alt='Show' src='http://fs2.directupload.net/images/150909/7tae9l8k.png' onclick='javascript:show()'></center>";
  42. }
  43. unsafeWindow.show = function(){
  44. document.cookie = 'sourcefunction=hide; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT;';
  45. }
  46. // ==============