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 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4 "use strict";
6 const { on } = require("../system/events");
7 const core = require("./core");
8 const { id: jetpackId} = require('../self');
10 const OPTIONS_DISPLAYED = "addon-options-displayed";
12 function onOptionsDisplayed({ subject: document, data: addonId }) {
13 if (addonId !== jetpackId)
14 return;
15 let query = 'setting[data-jetpack-id="' + jetpackId + '"][pref-name], ' +
16 'button[data-jetpack-id="' + jetpackId + '"][pref-name]';
17 let nodes = document.querySelectorAll(query);
18 for (let node of nodes) {
19 let name = node.getAttribute("pref-name");
20 if (node.tagName == "setting") {
21 let desc = core.get(name + "_description");
22 if (desc)
23 node.setAttribute("desc", desc);
24 let title = core.get(name + "_title");
25 if (title)
26 node.setAttribute("title", title);
28 for (let item of node.querySelectorAll("menuitem, radio")) {
29 let key = name + "_options." + item.getAttribute("label");
30 let label = core.get(key);
31 if (label)
32 item.setAttribute("label", label);
33 }
34 }
35 else if (node.tagName == "button") {
36 let label = core.get(name + "_label");
37 if (label)
38 node.setAttribute("label", label);
39 }
40 }
41 }
42 on(OPTIONS_DISPLAYED, onOptionsDisplayed);