查看当前页面源码

简爱代码>JavaScript2017-4-2 20:1737031

不堪大用的书签小工具一枚,主要用来查看当前页面的源码,编辑器使用的是 Ace.js

书签内容如下

javascript:(function(){l=location.pathname;r=/<body[^>]*>\s*<pre[^>]*>([\S\s]*)<\/pre>\s*<\/body>/i;h=(document.documentElement.outerHTML);h=r.test(h)?h.match(r)[1]:h;with(window.open()){document.write('<head><title>HTML Editor</title></head><pre id="editor" class="fullScreen" data-url="'+l+'">'+(h.replace(/</g,"&lt;").replace(/>/g,"&gt;"))+'</pre><script src="https://cdn.asilu.com/editor.js?'+(new Date).getTime()+'"><\/script>');document.close()}})();

还有一个附带的

刷新页面 CSS 的代码

javascript:(function(){/*@ 刷新页面 CSS 样式文件 */ var links = document.getElementsByTagName('link'); for(k in links){ var _link = links[k]; if(_link.rel != 'stylesheet' || !_link.href){ continue; } _link.href = _link.href.replace(/^(.*?)(\?.*|)$/, '$1') + '?' + (new Date).getTime(); } })();

都是保存为书签有效

下面是使用到的 开源项目 以及地址

  • 编辑器 https://ace.c9.io/
  • 代码格式化 http://jsbeautifier.org/
  • 代码爆炸插件 https://github.com/leMaik/code-blast-ace

本文出自简爱博客,转载时请注明出处及相应链接。

评论

  1. q123542017-04-05 17:06回复

    压缩包的密码是多少?

发表评论

电子邮件地址不会被公开。必填项已用*标注