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.
1 /* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 function findBody(node)
7 {
8 if (node.nodeType != Node.ELEMENT_NODE) {
9 return null;
10 }
11 var children = node.childNodes;
12 if (children == null) {
13 return null;
14 }
15 var length = children.length;
16 var child = null;
17 var count = 0;
18 while (count < length) {
19 child = children[count];
20 if (child.tagName == "BODY") {
21 dump("BODY found");
22 return child;
23 }
24 var body = findBody(child);
25 if (null != body) {
26 return body;
27 }
28 count++;
29 }
30 return null;
31 }
33 // Given the body element, find the first table element
34 function findTable(body)
35 {
36 // XXX A better way to do this would be to use getElementsByTagName(), but
37 // it isn't implemented yet...
38 var children = body.childNodes
39 if (children == null) {
40 return null;
41 }
42 var length = children.length;
43 var child = null;
44 var count = 0;
45 while (count < length) {
46 child = children[count];
47 if (child.nodeType == Node.ELEMENT_NODE) {
48 if (child.tagName == "TABLE") {
49 dump("TABLE found");
50 break;
51 }
52 }
53 count++;
54 }
56 return child;
57 }
59 // Change the table's caption
60 function changeCaption(table)
61 {
62 // Get the first element. This is the caption (maybe). We really should
63 // check...
64 var caption = table.firstChild
66 // Get the caption text
67 var text = caption.firstChild
69 // Append some text
70 text.append(" NEW TEXT")
71 }
73 changeCaption(findTable(findBody(document.documentElement)))