Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | // |
michael@0 | 8 | // Dump the html content in html format |
michael@0 | 9 | // |
michael@0 | 10 | function html(node) |
michael@0 | 11 | { |
michael@0 | 12 | var type = node.nodeType; |
michael@0 | 13 | if (type == Node.ELEMENT_NODE) { |
michael@0 | 14 | |
michael@0 | 15 | // open tag |
michael@0 | 16 | dump("<" + node.tagName) |
michael@0 | 17 | |
michael@0 | 18 | // dump the attributes if any |
michael@0 | 19 | attributes = node.attributes; |
michael@0 | 20 | if (null != attributes) { |
michael@0 | 21 | var countAttrs = attributes.length; |
michael@0 | 22 | var index = 0 |
michael@0 | 23 | while(index < countAttrs) { |
michael@0 | 24 | att = attributes[index]; |
michael@0 | 25 | if (null != att) { |
michael@0 | 26 | dump(" " + att.value) |
michael@0 | 27 | } |
michael@0 | 28 | index++ |
michael@0 | 29 | } |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | // close tag |
michael@0 | 33 | dump(">") |
michael@0 | 34 | |
michael@0 | 35 | // recursively dump the children |
michael@0 | 36 | if (node.hasChildNodes()) { |
michael@0 | 37 | // get the children |
michael@0 | 38 | var children = node.childNodes; |
michael@0 | 39 | var length = children.length; |
michael@0 | 40 | var count = 0; |
michael@0 | 41 | while(count < length) { |
michael@0 | 42 | child = children[count] |
michael@0 | 43 | html(child) |
michael@0 | 44 | count++ |
michael@0 | 45 | } |
michael@0 | 46 | dump("</" + node.tagName + ">"); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | |
michael@0 | 50 | } |
michael@0 | 51 | // if it's a piece of text just dump the text |
michael@0 | 52 | else if (type == Node.TEXT_NODE) { |
michael@0 | 53 | dump(node.data) |
michael@0 | 54 | } |
michael@0 | 55 | } |
michael@0 | 56 | |
michael@0 | 57 | html(document.documentElement) |
michael@0 | 58 | dump("\n") |