This file is indexed.

/usr/share/xul-ext/adblock-plus-element-hiding-helper/windowWrapper.js is in xul-ext-adblock-plus-element-hiding-helper 1.2.2-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
/*
 * This Source Code is subject to the terms of the Mozilla Public License
 * version 2.0 (the "License"). You can obtain a copy of the License at
 * http://mozilla.org/MPL/2.0/.
 */

let {Aardvark} = require("aardvark");
let {Prefs} = require("prefs");
let {KeySelector} = require("keySelector");

let key = undefined;

function getMenuItem()
{
	// Randomize URI to work around bug 719376
	let stringBundle = Services.strings.createBundle("chrome://elemhidehelper/locale/global.properties?" + Math.random());
	let result = [stringBundle.GetStringFromName("selectelement.label"), stringBundle.GetStringFromName("stopselection.label")];

	getMenuItem = function() result;
	return getMenuItem();
}

exports.WindowWrapper = WindowWrapper;
function WindowWrapper(wnd, elementMarkerClass)
{
	this.window = wnd;

	this.popupShowingHandler = this.popupShowingHandler.bind(this);
	this.popupHiddenHandler = this.popupHiddenHandler.bind(this);
	this.keyPressHandler = this.keyPressHandler.bind(this);
	this.toggleSelection = this.toggleSelection.bind(this);
	this.hideTooltips = this.hideTooltips.bind(this);

	this.E("ehh-elementmarker").firstElementChild.setAttribute("class", elementMarkerClass);

	this.init();
}
WindowWrapper.prototype =
{
	window: null,

	get browser()
	{
		if ("gBrowser" in this.window)
			return this.window.gBrowser;            // Firefox / SeaMonkey browser
		else if (typeof this.window.getBrowser == "function")
			return this.window.getBrowser();        // Thunderbird
		else if (typeof this.window.getMessageBrowser == "function")
			return this.window.getMessageBrowser(); // SeaMonkey mail

		throw new Error("Failed to find browser element in this application");
	},

	init: function()
	{
		this.window.addEventListener("popupshowing", this.popupShowingHandler, false);
		this.window.addEventListener("popuphidden", this.popupHiddenHandler, false);
		this.window.addEventListener("keypress", this.keyPressHandler, false);
		this.window.addEventListener("blur", this.hideTooltips, true);
	},

	shutdown: function()
	{
		this.window.removeEventListener("popupshowing", this.popupShowingHandler, false);
		this.window.removeEventListener("popuphidden", this.popupHiddenHandler, false);
		this.window.removeEventListener("keypress", this.keyPressHandler, false);
		this.window.removeEventListener("blur", this.hideTooltips, true);
	},

	E: function(id)
	{
		let doc = this.window.document;
		this.E = function(id) doc.getElementById(id);
		return this.E(id);
	},

	key: undefined,

	popupShowingHandler: function(event)
	{
		let popup = event.target;
		if (!/^(abp-(?:toolbar|status|menuitem)-)popup$/.test(popup.id))
			return;

		this.popupHiddenHandler(event);

		let enabled = Aardvark.canSelect(this.browser);
		let running = (enabled && this.browser == Aardvark.browser);

		let [labelStart, labelStop] = getMenuItem();
		let item = popup.ownerDocument.createElement("menuitem");
		item.setAttribute("label", running ? labelStop : labelStart);
		item.setAttribute("class", "elemhidehelper-item");
		if (!enabled)
			item.setAttribute("disabled", "true");

		if (typeof key == "undefined")
			this.configureKey(event.currentTarget);
		item.setAttribute("acceltext", KeySelector.getTextForKey(key));

		item.addEventListener("command", this.toggleSelection, false);

		let insertBefore = null;
		for (let child = popup.firstChild; child; child = child.nextSibling)
			if (/-options$/.test(child.id))
				insertBefore = child;
		popup.insertBefore(item, insertBefore);
	},

	popupHiddenHandler: function(event)
	{
		let popup = event.target;
		if (!/^(abp-(?:toolbar|status|menuitem)-)popup$/.test(popup.id))
			return;

		let items = popup.getElementsByClassName("elemhidehelper-item");
		while (items.length)
			items[0].parentNode.removeChild(items[0]);
	},

	keyPressHandler: function(event)
	{
		if (typeof key == "undefined")
			this.configureKey(event.currentTarget);

		if (KeySelector.matchesKey(event, key))
		{
			event.preventDefault();
			this.toggleSelection();
		}
	},

	configureKey: function(window)
	{
		key = new KeySelector(window).selectKey(Prefs.selectelement_key);
	},

	hideTooltips: function()
	{
		if (Aardvark.window == this.window)
			Aardvark.hideTooltips();
	},

	toggleSelection: function()
	{
		if ("@adblockplus.org/abp/public;1" in Cc && this.browser != Aardvark.browser)
			Aardvark.start(this);
		else
			Aardvark.quit();
	}
};