Get source code of website loaded in current tab - Chrome extension programming
I'm programming a host proof application which "by definition" requires to chcek source code on client side (html,js,css). This is best done (I believe) by extension for browser that takes source code, and generate checksum (e.g. sha1 or md5 which is implemented via javascript) Is there any way to get source code of currently opened tab ? (body.innerHTML or head.innerHTML is not enough) application is after developemen开发者_C百科t standalone, so all javascript,css is bundled into just one file, therefore checking is easy (no need for parsing and hashing any external scripts, style sheets,...)
body.innerHTML
and head.innerHTML
should be enough. On this test doc:
<script>alert("1");</script>
<html>
<script>alert("2");</script>
<head>
<title>test</title>
</head>
<script>alert("3");</script>
<body>
body
</body>
<script>alert("4");</script>
</html>
<script>alert("5");</script>
it automatically put alerts 1, 2, and 3 into head.innerHTML
, while alerts 4 and 5 went to body.innerHTML
.
精彩评论