Source Viewer

View Source Code of any homepage

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

  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.4
  7. // @icon http://file1.npage.de/007324/77/bilder/favicon.ico
  8. // @author Scriptz
  9. // @grant GM_addStyle
  10. // @grant unsafeWindow
  11. // @supportURL mailto:scriptz@mail1a.de?subject=Source Viewer
  12. // @copyright 2013+ , Scriptz
  13. // @license Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License; http://creativecommons.org/licenses/by-nc-nd/3.0/
  14. // ==/UserScript==
  15.  
  16. /* CHANGELOG
  17.  
  18. 6.7.0.4 (6/16/2016)
  19. - added changelog
  20. - added license
  21.  
  22. */
  23.  
  24. 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;}");
  25.  
  26. // ==Source==
  27. unsafeWindow.viewthesource = function(){
  28. window.location="view-source:"+window.location;
  29. };
  30. // ==============
  31.  
  32. // ==Body==
  33. body = document.body;
  34. if(body !== null) {
  35. div2 = document.createElement("div");
  36. div2.setAttribute('id','viewthesource');
  37. 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>";
  38. body.appendChild(div2);
  39. }
  40. // ==============
  41.  
  42. // ==Hide/Show==
  43. unsafeWindow.hide = function(){
  44. var a = new Date();
  45. a = new Date(a.getTime() +1000*60*60*24*365);
  46. document.cookie = 'sourcefunction=hide; path=/; expires='+a.toGMTString()+';';
  47. console.info('Set "sourcefunction=hide" cookie for '+window.location);
  48. 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;}");
  49. document.getElementById("viewthesource").innerHTML = "<center><img alt='Show' src='http://fs2.directupload.net/images/150909/7tae9l8k.png' onclick='javascript:show()'></center>";
  50. };
  51. if (document.cookie.indexOf("sourcefunction=hide") >= 0) {
  52. 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;}");
  53. document.getElementById("viewthesource").innerHTML = "<center><img alt='Show' src='http://fs2.directupload.net/images/150909/7tae9l8k.png' onclick='javascript:show()'></center>";
  54. }
  55. unsafeWindow.show = function(){
  56. document.cookie = 'sourcefunction=hide; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT;';
  57. console.warn('Delete "sourcefunction=hide" cookie for '+window.location);
  58. 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;}");
  59. 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>";
  60. };
  61. // ==============