Source Viewer

View Source Code of any homepage

当前为 2016-07-13 提交的版本,查看 最新版本

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