/usr/share/xul-ext/refcontrol/chrome/content/refcontrolOverlay.js is in xul-ext-refcontrol 0.8.16-2.
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | var refcontrolOverlay = {
monitoredPrefs:
{
enabled: 0,
statusbar: 0,
contextMenu: 0,
},
dump: function dump(aMessage)
{
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage("RefControl: " + aMessage);
},
dumpEx: function dumpEx(aException)
{
Components.utils.reportError(aException);
if ('stack' in aException)
{
var msg = new String(aException);
msg += "\n" + aException.stack;
this.dump(msg);
}
},
getString: function getString(sStringName)
{
return document.getElementById('refcontrol-strings').getString(sStringName);
},
isOurURL: function isOurURL(sURL)
{
var svcIO = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
try {
var uri = svcIO.newURI(sURL, null, null);
} catch (ex) {
return false;
}
return (uri.schemeIs('http') || uri.schemeIs('https'));
},
getLinkURL: function getLinkURL(contextMenu)
{
return typeof(contextMenu.linkURL) == 'function' ? contextMenu.linkURL() : contextMenu.linkURL;
},
openOptions: function openOptions(sSite)
{
var winOptions = openDialog('chrome://refcontrol/content/refcontrolOptions.xul',
'RefControlOptions',
'centerscreen,chrome,resizable,dialog=no',
(sSite !== undefined) ? { contextSite: sSite } : undefined);
try {
winOptions.focus();
} catch (ex) {
}
},
openOptionsURL: function openOptionsURL(sURL)
{
var svcIO = Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService);
this.openOptions(svcIO.newURI(sURL, null, null).host);
},
toolsOptions: function toolsOptions()
{
this.openOptions();
},
contextOptions: function contextOptions()
{
var sSite;
try {
sSite = window._content.document.location.hostname;
} catch (ex) {
}
this.openOptions(sSite);
},
contextOptionsLink: function contextOptionsLink()
{
this.openOptionsURL(this.getLinkURL(gContextMenu));
},
contextOptionsImage: function contextOptionsImage()
{
this.openOptionsURL(gContextMenu.imageURL);
},
onLoad: function onLoad()
{
window.addEventListener("unload", this, false);
window.getBrowser().addProgressListener(this);
document.getElementById("contentAreaContextMenu").addEventListener("popupshowing", this, false);
this.prefBranch = refcontrolPrefs.getPrefBranch();
this.prefBranch.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
if (this.prefBranch.getBoolPref('first_run'))
{
this.prefBranch.setBoolPref('first_run', false);
// old value of 1 (show icon in statusbar) is no longer applicable
if (this.prefBranch.getIntPref('statusbar') == 1)
this.prefBranch.setIntPref('statusbar', 0);
// add button to add-on bar if not already in a toolbar
var id = 'refcontrol-toolbarbutton';
if (!document.getElementById(id))
{
var toolbar = document.getElementById('addon-bar');
if (!toolbar)
toolbar = document.getElementById('nav-bar');
if (toolbar)
{
toolbar.insertItem(id);
toolbar.setAttribute("currentset", toolbar.currentSet);
document.persist(toolbar.id, "currentset");
if (toolbar.id == "addon-bar")
toolbar.collapsed = false;
}
}
}
for (var sPref in this.monitoredPrefs)
{
this.prefBranch.addObserver(sPref, this, true);
this.observe(this.prefBranch, 'nsPref:changed', sPref);
}
},
onUnload: function onUnload()
{
window.removeEventListener("unload", this, false);
for (var sPref in this.monitoredPrefs)
this.prefBranch.removeObserver(sPref, this);
this.prefBranch = null;
document.getElementById("contentAreaContextMenu").removeEventListener("popupshowing", this, false);
window.getBrowser().removeProgressListener(this);
},
onPopupShowing: function onPopupShowing(e)
{
var bShow = this.bShowContextMenu &&
!gContextMenu.isTextSelected && !gContextMenu.onLink && !gContextMenu.onImage && !gContextMenu.onTextInput &&
this.isOurURL(gContextMenu.target.ownerDocument.location.href); // gContextMenu.docURL
var bShowLink = this.bShowContextMenu &&
gContextMenu.onLink &&
this.isOurURL(this.getLinkURL(gContextMenu));
var bShowImage = this.bShowContextMenu &&
gContextMenu.onImage &&
this.isOurURL(gContextMenu.imageURL);
gContextMenu.showItem('refcontrol_sep', bShow || bShowLink || bShowImage);
gContextMenu.showItem('refcontrol_options', bShow);
gContextMenu.showItem('refcontrol_options_link', bShowLink);
gContextMenu.showItem('refcontrol_options_image', bShowImage);
},
// Implement nsIEventListener
handleEvent: function handleEvent(evt)
{
try {
switch (evt.type)
{
case 'load':
// workaround https://bugzilla.mozilla.org/show_bug.cgi?id=174320
setTimeout(function(myThis) { window.removeEventListener("load", myThis, false); }, 0, this);
return this.onLoad(evt);
case 'popupshowing':
return this.onPopupShowing(evt);
case 'unload':
return this.onUnload(evt);
default:
this.dump("handleEvent: unknown event: " + evt.type);
}
} catch (ex) {
this.dumpEx(ex);
}
return undefined;
},
onChangeEnabled: function onChangeEnabled(oPrefBranch)
{
this.bEnabled = oPrefBranch.getBoolPref('enabled');
this.updateToolbarButton();
},
onChangeStatusbar: function onChangeStatusbar(oPrefBranch)
{
this.showStatusbar = oPrefBranch.getIntPref("statusbar");
this.updateStatusbar();
},
onChangeContextMenu: function onChangeContextMenu(oPrefBranch)
{
this.bShowContextMenu = oPrefBranch.getBoolPref('contextMenu');
},
// Implement nsIObserver
observe: function observe(aSubject, aTopic, aData)
{
try {
switch (aTopic)
{
case 'nsPref:changed':
aSubject.QueryInterface(Components.interfaces.nsIPrefBranch);
switch (aData)
{
case 'enabled':
this.onChangeEnabled(aSubject);
break;
case 'statusbar':
this.onChangeStatusbar(aSubject);
break;
case 'contextMenu':
this.onChangeContextMenu(aSubject);
break;
default:
this.dump("observe: unknown pref changing: " + aData);
break;
}
break;
default:
this.dump("observe: unknown topic: " + aTopic);
break;
}
} catch (ex) {
this.dumpEx(ex);
}
},
updateToolbarButton: function()
{
var tbb = document.getElementById("refcontrol-toolbarbutton");
if (tbb)
tbb.setAttribute("enabled", this.bEnabled ? "true" : "false");
},
updateStatusbar: function updateStatusbar()
{
var sb = document.getElementById("refcontrol-status");
if (this.showStatusbar <= 1)
{
sb.setAttribute("collapsed", true);
return;
}
var theWindow = ("gBrowser" in window) ? window.gBrowser.contentWindow : window.frames[0];
var sRef = theWindow.document.referrer;
var sRefDisp = (sRef ? sRef : this.getString("StatusbarNoReferer"));
var sbText = document.getElementById("refcontrol-status-text");
sbText.value = sRefDisp;
sbText.setAttribute("tooltiptext", sRefDisp);
sb.removeAttribute("collapsed");
},
// Implement nsIWebProgressListener
onLocationChange: function onLocationChange(aWebProgress, aRequest, aLocation)
{
try {
this.updateStatusbar();
} catch (ex) {
this.dumpEx(ex);
}
},
onProgressChange: function(webProgress, request, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) {},
onSecurityChange: function(webProgress, request, state) {},
onStateChange: function(webProgress, request, stateFlags, status) {},
onStatusChange: function(webProgress, request, status, message) {},
// end Implement nsIWebProgressListener
// see http://forums.mozillazine.org/viewtopic.php?t=49716
onLinkIconAvailable: function(a) {},
// Implement nsISupports
QueryInterface: function QueryInterface(aIID)
{
if (aIID.equals(Components.interfaces.nsIObserver) ||
aIID.equals(Components.interfaces.nsIWebProgressListener) ||
aIID.equals(Components.interfaces.nsIEventListener) ||
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
aIID.equals(Components.interfaces.nsISupports))
{
return this;
}
throw Components.results.NS_ERROR_NO_INTERFACE;
}
};
window.addEventListener("load", refcontrolOverlay, false);
|