PK `4ycontent/SDdBcd`ia``0bbFV0UH n&9I73n9F&&Vaxaa%' @B&`WUT DDDPK -4d ycontent/adblock.cssSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT UDDDadblock[id="adblock-load-mechanism"] { -moz-binding: url("chrome://adblock/content/adblock.xml#adblockloadmechanism") !important; } statusbarpanel[id="adblock-status"] { /*min-width: 10px;*/ min-width: 12ex !important; width: 12ex !important; /* relative length, measured from element-font's x-height */ white-space: nowrap; -moz-binding: url("chrome://adblock/content/adblock.xml#statusbarpanel") !important; } statusbarpanel[id="adblock-status"][status="enabled"] { -moz-outline: none !important; } statusbarpanel[id="adblock-status"][status="enabled"] > [id="adblock-status-text"] { color: #333333; } statusbarpanel[id="adblock-status"][status="enabled"][whitelisted="true"] > [id="adblock-status-text"] { -moz-outline: #DDDDFF dotted 4px !important; color: #444499; } statusbarpanel[id="adblock-status"][status="enabled"]:hover > [id="adblock-status-text"] { color: #993333; cursor: pointer; } statusbarpanel[id="adblock-status"][status="enabled"][whitelisted="true"]:hover > [id="adblock-status-text"] { -moz-outline: #DDDDFF dotted 4px !important; color: #993333; cursor: pointer; } statusbarpanel[id="adblock-status"][status="enabled"]:hover { cursor: pointer; } statusbarpanel[id="adblock-status"][status="notlistening"] > [id="adblock-status-text"] { color: #999999; } statusbarpanel[id="adblock-status"][status="notlistening"]:hover > [id="adblock-status-text"] { color: #995555; cursor: pointer; } statusbarpanel[id="adblock-status"][status="notlistening"]:hover { cursor: pointer; } statusbarpanel[id="adblock-status"][status="unloaded"] > [id="adblock-status-text"] { color: #999999; } statusbarpanel[id="adblock-status"][quickblock="full"] > [id="adblock-status-text"] { border-width: 0 0 1px 0; border-color: inherit; border-style: none none solid none; } statusbarpanel[id="adblock-status"][quickblock="partial"] > [id="adblock-status-text"] { border-width: 0 0 1px 0; border-color: inherit; border-style: none none dashed none; } statusbarpanel[id="adblock-status"][quickblock="off"] > [id="adblock-status-text"] { border-width: 0 0 1px 0; border-color: transparent; border-style: none none solid none; } statusbarpanel[id="adblock-status"][flashblock="active"] > [id="adblock-status-text"] { } statusbarpanel[id="adblock-status"][flashblock="inactive"] > [id="adblock-status-text"] { } /* status drag-n-drop borders */ statusbar[abdrag="true"] > statusbarpanel { border-right-width: 2px !important; border-right-style: dotted !important; border-right-color: #AB0000 !important; } /* statusbar > statusbarpanel > * { border-right-width: 2px !important; border-right-style: dotted !important; border-right-color: transparent !important; } statusbar[abdrag="true"] > statusbarpanel > * { border-right-color: #AB0000 !important; } */ PK Z49Sycontent/adblock.jsSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT tDDD// Bool: did adblock successfully load (set by adblock.xul) -- global var. var Loaded; // Bool: is adblock enabled (set by pref-observer) -- global var. var Enabled; // Bool: quickblock background-images (set by pref-observer) -- global var. var QuickblockBackground; // Status element drag-n-drop var abDrag = function(evt) { clearTimeout(window.abDragCleanup); if (!adblockStatusDrag.statusbar.abDrag) { adblockStatusDrag.statusbar.setAttribute("abdrag", true); // css takes care of stylin' adblockStatusDrag.statusbar.abDrag = true; } //adblockStatusDrag.showBorders(); /*window.addEventListener("dragexit", function(evt, session) { if (adblockStatusDrag.statusbar.abDrag) adblockStatusDrag.scheduleCleanup(); }, true);*/ // these are lost after the drop if (!evt.target.dragLoaded) { evt.target.dragLoaded = true; evt.target.addEventListener("mouseup", function() { setTimeout('adblockStatusDrag.dragCleanup();',5); }, true); } var modEvt = { originalTarget:evt.originalTarget, target:evt.target, preventBubble:function(){} }; evt.preventBubble(); setTimeout(function(modEvt) {nsDragAndDrop.startDrag(modEvt, adblockStatusDrag);}, 50, modEvt); }; var adblockStatusDrag = { load: function() { var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader); loader.loadSubScript('chrome://global/content/nsDragAndDrop.js'); loader.loadSubScript('chrome://global/content/nsTransferable.js'); dragEnter = function(evt) { nsDragAndDrop.dragEnter(evt, adblockStatusDrag); }; dragOver = function(evt) { nsDragAndDrop.dragOver(evt, adblockStatusDrag); }; // required for drop dragDrop = function(evt) { nsDragAndDrop.drop(evt, adblockStatusDrag); }; dragExit = function(evt) { nsDragAndDrop.dragExit(evt, adblockStatusDrag); }; dragCleanup = function() { adblockStatusDrag.dragCleanup(); }; // adblock status-element this.status = document.getElementById("adblock-status"); this.status.addEventListener("draggesture", abDrag, true); // statusbar this.statusbar = document.getElementById("status-bar"); var child = this.statusbar.firstChild, x = 0, defaultDropArray = new Array(); while (child) { if (child != this.status) { if (!child.id) { var newId = "statusbarpanel-noID"+x; while (document.getElementById(newId)) newId += "x"+x; child.id = newId; child.setAttribute("persist", new String("id" + (child.persist ? " "+child.persist : "")) ); x++; } try { if (child.childNodes.length == 0 && document.getAnonymousNodes(child).length == 0) child.setAttribute("abnochildren", true); } catch (e) {} child.addEventListener("dragenter", dragEnter, true); child.addEventListener("dragover", dragOver, true); child.addEventListener("dragdrop", dragDrop, true); //child.addEventListener("dragexit", dragExit, true); } defaultDropArray.unshift(child.id); child = child.nextSibling; } // global window.addEventListener("dragexit", dragExit, true); return defaultDropArray; // so our load-call (prefObserver) can Right-align against these, by default }, /* statusbar drag-notifier */ onDragStart: function (evt, transferData, action) { transferData.data = new TransferData(); transferData.data.addDataForFlavour("adblock-status-id", this.status.id); }, /* statusbar drag-listener */ getSupportedFlavours: function () { var flavours = new FlavourSet(); flavours.appendFlavour("adblock-status-id"); return flavours; }, onDragEnter: function(evt, session) { /*"mouseover"*/ if (session.sourceNode == this.status) this.showBorders(); //logfile(unlimitedListObject(session)); }, onDragOver: function (evt, flavour, session) { /*"mousemove"*/ /*evt.target.setAttribute("style", "-moz-outline: #AB0000 dotted 2px !important");*/ }, xxcanDrop: function(evt, mDragSession) { return true; }, // whoa- there can be ABSOLUTELY NO DELAYS INLINE: no throw(), alert(), etc. onDrop: function (evt, dropdata, session) { this.scheduleCleanup(); var parent = this.statusbar; var prev = evt.target; while (prev.nodeName.toLowerCase() != "statusbarpanel") prev = prev.parentNode; var midPointCoord = prev.boxObject.x + (prev.boxObject.width/2); // the offset + midpoint midPointCoord += !prev.previousSibling ? (prev.boxObject.width/4) // + additional quarter-coverage for left-most panel : (!prev.nextSibling ? (-prev.boxObject.width/4) : 0); // - less quarter-coverage for right-most panel if (evt.clientX < midPointCoord) prev = prev.previousSibling; var next = (!prev) ? parent.firstChild : (prev.nextSibling != this.status) ? prev.nextSibling : prev.nextSibling.nextSibling; prevString = new Array(); for (var i=0, children=parent.childNodes; i (this.statusbar.boxObject.width/2)) // offset+.75width is over the statusbar midpoint prevString.push(children[i].id); prevString = prevString.reverse().join(","); //adblockPrefObserver.Branch.setCharPref("statusdrop", prevString); // pref-observer will relocate element var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); var adblockBranch = "adblock."; var Branch = prefService.getBranch(adblockBranch); Branch.setCharPref("statusdrop", prevString); // pref-observer will relocate element prefService.savePrefFile(null); // save the prefs to disk }, onDragExit: function(evt, session) { /*"mouseout"*/ if (session.sourceNode == this.status) this.scheduleCleanup(); //logfile(unlimitedListObject(session)); }, showBorders: function() { clearTimeout(window.abDragCleanup); if (!this.statusbar.abDrag) { this.statusbar.setAttribute("abdrag", true); // css takes care of stylin' this.statusbar.abDrag = true; } }, scheduleCleanup: function(evt) { clearTimeout(window.abDragCleanup); window.abDragCleanup = setTimeout('adblockStatusDrag.dragCleanup();',700); }, dragCleanup: function(debug) { this.statusbar.setAttribute("abdrag", false); this.statusbar.abDrag = false; //setTimeout("throw('exit: "+debug+"');", 0); } }; // Preferences observer object; implements nsIObserver var adblockPrefObserver = { // Called on window-load load: function(n) { window.removeEventListener("load", abLoad, true); // remove startup-check -- only run once this.console = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService); var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); var appShell = Components.classes["@mozilla.org/appshell/appShellService;1"].getService(Components.interfaces.nsIAppShellService); var hiddenWnd = appShell.hiddenDOMWindow; observerService.notifyObservers(null, "Adblock-LoadFromProfile", null); // copy the apiConstants to the hidden-window, in case we loaded from the root-component observerService.notifyObservers(null, "Adblock-LoadAPIConstants", null); // copy the apiConstants to the hidden-window, in case we loaded from the root-component // load component if (typeof(Components.classes["@mozilla.org/adblock;1"]) == 'undefined' /*|| !hiddenWnd.apiConstants*/) { // switching profiles "live" will still show the component registered, without benefit of anything being in the hidden-window, anymore //hiddenWnd.abNonRootLoad = true; //Components.classes["@mozilla.org/moz/jssubscript-loader;1"].createInstance(Components.interfaces.mozIJSSubScriptLoader).loadSubScript("chrome://adblock/content/component.js", hiddenWnd); //observerService.notifyObservers(null, "Adblock-LoadAPIConstants", null); // copy the apiConstants to the hidden-window, in case we loaded from the root-component //Loaded = true; } // we should use an array in the hidden-window to set this when *really* loaded Loaded = false; } else Loaded = true; if (!hiddenWnd.apiConstants) abComponentCheck(hiddenWnd); this.apiConstants = hiddenWnd.apiConstants; this.isPendingRestart = hiddenWnd.isPendingRestart; this.isPendingCallback = hiddenWnd.isPendingCallback; this.isWhite = hiddenWnd.isWhite; this.addWhite = hiddenWnd.addWhite; if (!hiddenWnd.abPrefsLoaded) { observerService.notifyObservers(null, "Adblock-LoadPrefs", null); // load all prefs, now that we're ensured a profile to draw from hiddenWnd.abPrefsLoaded = true; } window.document.AdblockQuickblocked = false; // initialize quickblock tag -- *before* pref-observer window.document.addEventListener("popupshown", adblockSetContext, true); // sets the context-menu items window.document.addEventListener("adblock-pageblock", adblockPageBlockListener, true); // sets the url / uri for pageblocked tabs var Tabbrowser = window.getBrowser(), Tabs = Tabbrowser.mTabContainer; Tabbrowser.addEventListener('load', this.onTabChangeOuter, true); // status-whitelist update when loaded (normal) Tabbrowser.addEventListener('pageshow', this.onTabChangeOuter, true); // status-whitelist update when loaded (from bfcache) Tabs .addEventListener('select', this.onTabChangeOuter, true); // status-whitelist update when switching tabs var prefService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); this.adblockBranch = "adblock."; this.Branch = prefService.getBranch(this.adblockBranch); this.windowInit = false; this.statusElement = null, this.statusText = null; this.mainRe = /^adblock\.(enabled|quickblock|quickblockbackground|statusdrop)/; var pref = prefService.getBranch(null); // preferences root node this.pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal); this.pbi.addObserver(this.adblockBranch, this, true); // keep this last, in case we hit an error. this.observe(null, null, null); }, // update status-element for whitelist style, on page/tab-load, select, or close onTabChangeOuter: function(evt) { adblockPrefObserver.onTabChange(evt); }, onTabChange: function(evt) { if (!this.statusElement||!this.statusElement.parentNode) return; var whiteType = null, status = this.statusElement; try{ whiteType = this.isWhite(content.location+''); }catch(e){} var isStyled = status.hasAttribute('whitelisted'), updated; if (whiteType!=null) !isStyled && (updated=true) && status.setAttribute('whitelisted',true); //this.statusText.setAttribute('style','color: #444499 !important; -moz-outline: #DDDDFF dotted 4px !important;'); //'whitelisted',true); else isStyled && (updated=true) && status.removeAttribute('whitelisted'); //this.statusText.removeAttribute('style'); // toggle visibility, to ensure repaint occurs if (updated) status.hidden = true, setTimeout(function(){status.hidden = false;},0); }, log: function(msg) { this.console.logStringMessage(msg); }, // nsISupports interface implementation -- for weak-reference by pref-observer service QueryInterface: function(iid) { if (!iid.equals(Components.interfaces.nsISupports) && !iid.equals(Components.interfaces.nsISupportsWeakReference) && !iid.equals(Components.interfaces.nsIObserver)) { dump("Adblock Window Pref-Observer factory object: QI unknown interface: " + iid + "\n"); throw Components.results.NS_ERROR_NO_INTERFACE; } return this; }, // removes the observer-object from service -- called when the window is no longer open removeObserver: function() { this.pbi.removeObserver(this.adblockBranch, this); delete this; }, // observer-function /* subject: [wrapped nsISupports :: nsIPrefBranch], nsIPrefBranchInternal topic: "changed"*/ observe: function(subject, topic, prefName) { // if we don't have a valid window (closed) if ( !(typeof(document) == 'object' && document) ) { this.removeObserver(); // remove the observer.. return; } // ..and don't continue if (this.windowInit && prefName=="adblock.white") return this.onTabChange(null); // on window-init, OR a status-critical pref change if (!this.windowInit || this.mainRe.test(prefName)) { /* Globals and Status-Element */ // Create status-element pointers if (!this.windowInit) { this.statusElement = document.getElementById("adblock-status"); this.statusText = document.getAnonymousNodes(this.statusElement)[1]; this.defaultDropArray = window.adblockStatusDrag.load(); // load drag-listeners + default right-alignment } // Status drag-insertion if (!this.windowInit || prefName == "adblock.statusdrop") { if (this.Branch.prefHasUserValue("statusdrop")) var dropArray = this.Branch.getCharPref("statusdrop").split(","); else dropArray = this.defaultDropArray; //else dropArray = "statusbar-updates,progressmeter-statusbar,statusbarpanel-progress,page-theme-button,page-report-button,security-button,privacy-button,offline-status,popupIcon,statusbar-display,component-bar".split(","); var dropPoint = null; while (dropArray.length>0 && !dropPoint) dropPoint = document.getElementById(dropArray.shift()); var parent = this.statusElement.parentNode; var next = (!dropPoint) ? parent.firstChild : (dropPoint.nextSibling != this.statusElement) ? dropPoint.nextSibling : this.statusElement.nextSibling; this.statusElement.removeEventListener("draggesture", abDrag, true); this.statusElement.dragReload = true; if (next) parent.insertBefore(parent.removeChild(this.statusElement), next); else parent.appendChild(parent.removeChild(this.statusElement)); this.statusElement.dragReload = false; this.statusElement.addEventListener("draggesture", abDrag, true); this.statusElement.dragLoaded = false; // we duplicate this in the statuselement's binding, now -- to catch statusbar visibility, when initially off //this.statusText = document.getAnonymousNodes(this.statusElement)[1]; // element is rebound on insertion if (this.windowInit) this.observe(null, null, "adblock.enabled"); // we have to reload the status-text } var boolType = Components.interfaces.nsIPrefBranch.PREF_BOOL, type="getPrefType"; var charType = Components.interfaces.nsIPrefBranch.PREF_STRING; // Enabled / Disabled if (!this.windowInit || prefName == "adblock.enabled") { if (this.isPendingRestart) this.statusText.value = this.isPendingRestart, this.statusElement.setAttribute("status", "enabled"); else { Enabled = !(this.Branch[type]("enabled")==boolType) || this.Branch.getBoolPref("enabled"); // default:true if (!Loaded) { this.statusText.value = "Unloaded"; this.statusElement.setAttribute("status", "unloaded"); this.statusElement.setAttribute("tooltiptext", "Adblock failed to load"); } else if (!Enabled) { this.statusText.value = "Disabled"; this.statusElement.setAttribute("status", "notlistening"); this.statusElement.setAttribute("tooltiptext", "Adblock is disabled"); } else { this.statusText.value = "Adblock"; this.statusElement.setAttribute("status", "enabled"); this.statusElement.setAttribute("tooltiptext", "Adblock is enabled"); } } } // Quickblock if (!this.windowInit || prefName == "adblock.quickblock") { var quickLevel = null; if (this.Branch[type]("quickblock") == boolType) quickLevel = this.Branch.getBoolPref("quickblock") ? "partial" : "off"; // convert old bool-type pref to new else if (this.Branch[type]("quickblock") == charType) quickLevel = this.Branch.getCharPref("quickblock"); if (quickLevel != null) this.statusElement.setAttribute("quickblock", quickLevel), loadQuickblock(quickLevel); } // QuickblockBackground if (!this.windowInit || prefName == "adblock.quickblockbackground") QuickblockBackground = (this.Branch.prefHasUserValue("quickblockbackground") && this.Branch.getBoolPref("quickblockbackground")); // default:false // window-init if (!this.windowInit) { // disable conflicting key-bindings var conflictingKeys, adblockKeys = ["b", "a", "f", "p", "k"]; for (var n = 0 ; n < adblockKeys.length ; n++) { conflictingKeys = document.getElementsByAttribute("key", adblockKeys[n]); for (var q = 0 ; q < conflictingKeys.length ; q++) if (!( /adblock/.test(conflictingKeys[q].getAttribute("id")) ) && conflictingKeys[q].hasAttribute("modifiers")) if (/accel/.test(conflictingKeys[q].getAttribute("modifiers")) && /shift/.test(conflictingKeys[q].getAttribute("modifiers")) ) conflictingKeys[q].parentNode.removeChild(conflictingKeys[q]); } // flag as initialized this.windowInit = true; } } } }; // Install the root-Component -- for profile-installs, where the app might be replaced from under us function abComponentCheck(hiddenWnd) { var windowMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); /*try{ var dirService = Components.classes[DIRSERVICE_CONTRACTID].getService(Components.interfaces.nsIProperties); var compDir = dirService.get("ComsD", Components.interfaces.nsIFile); // component directory magic-key var existingComponent = compDir.clone(); existingComponent.append("nsAdblock.js"); var isInstalled = existingComponent.exists() ? true : false; } catch(e) {} if (!(existingComponent && isInstalled)*/ var ee; try { var dirService = Components.classes['@mozilla.org/file/directory_service;1'].getService(Components.interfaces.nsIProperties); var compDir = dirService.get("ComsD", Components.interfaces.nsIFile); // component directory magic-key var chromDir = dirService.get("UChrm", Components.interfaces.nsIFile); // profile chrome magic-key var d = dirService, g="get", f=Components.interfaces.nsIFile; var stuff, nameArray = [[".autoreg","ProfD"],[".autoreg","XCurProcD"],[".autoreg","ComsD"],["nsAdblock.js", "ComsD"]], count=nameArray.length, finished={}, alreadyPresent={}; // http://lxr.mozilla.org/seamonkey/source/xpcom/io/nsDirectoryServiceDefs.h while ((stuff=nameArray.shift())) { var name=stuff[0], key=stuff[1]; var source = chromDir.clone(); source.append(name); var destDir = d[g](key,f); var dest = destDir.clone(); dest.append(name); if (source.exists()) { try{ if ( dest.exists()) log("alreadyPresent: "+name), alreadyPresent[name]=true, dest.remove(true); }catch(e){} if (!dest.exists()) source.copyTo(destDir, name), count--, finished[name]=true; } } if (alreadyPresent["nsAdblock.js"]) { var regArray = ["compreg.dat","xpti.dat"], n2=""; n=1; while((name=regArray.shift())) { var regFile = compDir.clone(); regFile.append(name); try{ if (regFile.exists()) regFile.remove(true); }catch(e){} try{ var uninstalledName = "adblock-uninstalled"+n2; uninstalledFile = compDir.clone(); uninstalledFile.append(uninstalledName); while(uninstalledFile.exists()) uninstalledFile = compDir.clone(), uninstalledFile.append(uninstalledName+(n++)), n2=n; }catch(e){} try{ if (regFile.exists()) regFile.moveTo(compDir, uninstalledName); }catch(e){} } var msg = "Adblock has updated the Component-registry.\n\nApologies for the extra step: \n"; } } catch(e) { ee=e; } if (/*count==0||*/(finished && finished["nsAdblock.js"])) { if (!msg) msg = "Adblock's root-Component is now installed.\n\n" var lastWindow = windowMediator.getMostRecentWindow("navigator:browser"); var callback = function(wnd) { //var wnd = windowMediator.getMostRecentWindow("navigator:browser"); // yes- again, so we have the window directly in front of the user. if (!wnd||wnd.closed) wnd = windowMediator.getMostRecentWindow("navigator:browser"); var shouldRestart = wnd.confirm(msg+"Click OK to relaunch the browser:"); if (shouldRestart) var appShell = Components.classes["@mozilla.org/appshell/appShellService;1"].getService(Components.interfaces.nsIAppShellService); var hiddenWnd = appShell.hiddenDOMWindow; try{ Components.classes["@mozilla.org/moz/jssubscript-loader;1"].createInstance(Components.interfaces.mozIJSSubScriptLoader).loadSubScript("chrome://adblock/content/uninstall.js",hiddenWnd), // "do it." hiddenWnd.shutdownAppNow(); }catch(e){} } function callbackEncapsulate() { lastWindow.removeEventListener("load", callbackEncapsulate, true); lastWindow.setTimeout(callback,3000,lastWindow); } //lastWindow.setTimeout(callback,5000); lastWindow.addEventListener("load", callbackEncapsulate, true); adblockPrefObserver.log(msg + "Please relaunch the browser."); hiddenWnd.isPendingRestart = "Restart"; //"Please Restart Your Browser"; hiddenWnd.isPendingCallback = callback; } else { // XXX should we toss an alert directly, here? ..cons: it would become extremely annoying, seeing it each restart. msg = "Adblock is not yet enabled:\n\nMake sure the browser is located on a write-accessible disk. ...Then, quit and re-launch. The missing Component will be installed, at startup."; if (!lastWindow||lastWindow.closed) lastWindow = windowMediator.getMostRecentWindow("navigator:browser"); callback = function() { var wnd = windowMediator.getMostRecentWindow("navigator:browser"); wnd.alert(msg); } adblockPrefObserver.log(msg + (ee?("\n\n"+ee):"") ); //msg = "Adblock's root-Component failed to install. \n\nMake sure you have write privileges for the application folder"+(ee?("\n\n"+ee):""); //throw msg; // stop further loading (status will show 'Unloaded'); de-install will still be an option, from preferences hiddenWnd.isPendingRestart = "Pending"; //"Adblock must be Re-Installed"; hiddenWnd.isPendingCallback = callback; } } /*Check necessary files exist in Mozilla*/ //checkFilesMoz(); function checkFilesMoz() { // get files var compFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile); compFile.append("components"); compFile.append("nsAdblock.js"); var regFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile); regFile.append("components"); regFile.append(".autoreg"); // if missing backup files or is Firefox return if (!compFile.exists() || !regFile.exists()) return; // copy backup files into program directory if they don't exist. var testCompFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ComsD", Components.interfaces.nsIFile); testCompFile.append("nsAdblock.js"); var testRegFile = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ComsD", Components.interfaces.nsIFile); testRegFile.append(".autoreg"); var restart = false; if (!testCompFile.exists()) { var compDir = Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ComsD", Components.interfaces.nsIFile); compFile.copyTo(compDir, null); try {testRegFile.remove(false);} catch (e) {} regFile.copyTo(compDir, null); restart = true; } if (restart) window.setTimeout("alert('Please restart browser for Adblock to work.');", 20); } // runs the pref-observer once, by changing a dummy-pref // -- called by the status-element's binding 'onconstruct' (adblock.xml) function initAdblockPrefObserver() { try { var prefObj = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); var Branch = prefObj.getBranch("adblock."); var tempPref = (Branch.prefHasUserValue("observer")) ? Branch.getCharPref("observer") : "-"; // default:'-' :P switch (tempPref) { case "-": Branch.setCharPref("observer", "*"); break; case "*": Branch.setCharPref("observer", "-"); break; } } catch(e) {} } // toggles the adblock-enable pref -- enabling / disabling blocking function toggleAdblockEnable() { if (!Loaded) return; var prefObj, Branch; if (Enabled) try { prefObj = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); Branch = prefObj.getBranch("adblock."); Branch.setBoolPref("enabled", false); } catch(e) { alert("Adblock could not be disabled:\n\n" + e); } else try { prefObj = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); Branch = prefObj.getBranch("adblock."); Branch.setBoolPref("enabled", true); } catch(e) { alert("Adblock could not be enabled:\n\n" + e); } } // Checks an element and its children recursively for an attribute. function adblockFindAttribute(element, name) { if (element.hasAttribute(name)) { return element.getAttribute(name); } if (element.hasChildNodes()) { for (var i = 0 ; i < element.childNodes.length ; i++) { var res = adblockFindAttribute(element.childNodes[i], name); if (res != false) return res; } } return false; // Didn't find it! } // sets the url / uri for pageblocked tabs function adblockPageBlockListener(evt) { //var pageElementLocal = (evt.target.wrappedJSObject) ? evt.target.wrappedJSObject : evt.target; var pageElementLocal = evt.target; var browsers = window.getBrowser().browsers; // the .getBrowser method resolves tabbed vs. non-tabbed modes -- otherwise, we'd just get .browsers directly // contentWindow: local window - contentDocument: local document for (var i = 0, match = false; i < browsers.length &! match; i++) { try { if (browsers[i].contentDocument == pageElementLocal.ownerDocument) match = browsers[i]; } // end loop catch(e) {alert("Adblock: unable to access browsers[" + i + "].contentWindow:\n\n" + e);} } if (!match) return; //match.currentURI.spec = pageElementLocal.adblockURI.spec; // initialize the blocked-uri, so the urlbar displays proper on tab-switch if (match == window.getBrowser().selectedBrowser) gURLBar.value = pageElementLocal.adblockURI.spec; // set the urlbar manually, if this is the current browser var title = "Adblocked: "+pageElementLocal.adblockURI.host.replace(/^www\./, ""); match.contentDocument.title = title; //match.webNavigation.stop(Components.interfaces.nsIWebNavigation.STOP_ALL); // no further loading var curHistory = match.webNavigation.sessionHistory; var blockedURL = pageElementLocal.adblockURI.spec; // the url we blocked // if a different page was already loaded if (curHistory.index == -1 || curHistory.getEntryAtIndex(curHistory.index, false).URI.spec != blockedURL) { var ioService = Components.classes['@mozilla.org/network/io-service;1'].getService(Components.interfaces.nsIIOService); var newEntry = Components.classes['@mozilla.org/browser/session-history-entry;1'].createInstance(Components.interfaces.nsISHEntry); var newURI = ioService.newURI(blockedURL, null, null); var origIndex = curHistory.index; //var title = "Adblocked: "+pageElementLocal.adblockURI.host.replace(/^www\./, ""); newEntry.SetURI(newURI); newEntry.SetTitle(title); curHistory.QueryInterface(Components.interfaces.nsISHistoryInternal); curHistory.addEntry(newEntry, true); // add a history-item for the unblocked-page curHistory.index = origIndex++; //alert(origIndex+" "+curHistory.index); //match.webNavigation.gotoIndex(origIndex+1); //match.contentDocument.title = "Adblocked: "+title; } } // sets quickblock pref -- pref-observer catches this function toggleQuickblockEnable() { try { var prefObj = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); var Branch = prefObj.getBranch("adblock."); } catch(e) { alert("Quickblock could not be toggled:\n\n" + e); return; } if (Branch.getPrefType("quickblock") == Components.interfaces.nsIPrefBranch.PREF_BOOL) { var quickLevel = Branch.getBoolPref("quickblock") ? "partial" : "off"; // convert old bool-type pref to new Branch.deleteBranch("quickblock"); } else quickLevel = Branch.getCharPref("quickblock"); var nextLevel; switch (quickLevel) { case "off": nextLevel = "partial"; break; case "partial": nextLevel = "full"; break; case "full": nextLevel = "off"; break; } Branch.setCharPref("quickblock", nextLevel); // set the pref } // loads appropriate level of quickblock -- called by pref-observer function loadQuickblock(quickLevel) { switch (quickLevel) { case "full": if (typeof(window._Quickblock) != 'undefined') break; // the listeners are already attached, from 'partial' case "partial": window.document.addEventListener("dblclick", adblockQuickblock, true); // disable link-clicks.. window.document.addEventListener("click", adblockQuickblock, true); // ..and again window.document.addEventListener("mousedown", adblockQuickblock, true); // quickblock listener break case "off": window.document.removeEventListener("mousedown", adblockQuickblock, true); // remove listener window.document.removeEventListener("click", adblockQuickblock, true); window.document.removeEventListener("dblclick", adblockQuickblock, true); try{ window.document.removeEventListener("mousemove", adblockQuickblock, true); window.document.removeEventListener("mouseup", adblockQuickblock, true); } catch(e) {} break; } window._Quickblock = quickLevel; // store the level, so quickblock-listeners know what to do } // intercepts mouse-clicks and hides the dom-elements beneath function adblockQuickblock(evt) { var evType = evt.type, evButton = evt.button, evShift = evt.shiftKey, evCount = evt.detail; var fullBlock = (window._Quickblock == "full") ? true : false; // bool: trap single-clicks too? var item = evt.originalTarget; var itemContainer = evt.target; var deepItem = evt.explicitOriginalTarget; var deepReplacement, deepStyle, itemTag, tagRe; // if quickdrag is ending (mouseup), or the event is new (mouse left the window-area while dragging) // ..disable quickdrag and return if (window._Quickdrag && (evType == "mouseup" || evType == "mousedown" || (evType == "mousemove" &! evShift))) { delete window._Quickdrag; window.document.removeEventListener("mousemove", adblockQuickblock, true); window.document.removeEventListener("mouseup", adblockQuickblock, true); return; } // from here on, only shifted / non-form-submission events matter -- evCount registers at max for form-submission keypresses if (!evShift || (evType == "click" && evCount > 3)) return; // if this is a webpage-element -- for now, all xul-elements remain unblocked (because of window-scrollbars) if ((item != itemContainer) && (item.ownerDocument.baseURI) && (item.prefix != "xul")) { // if we shift-(double)clicked ( +~ drag) if ( ((evType == "dblclick" || (evType == "click" && fullBlock) || (evType == "mousedown" && (evCount > 1 || fullBlock) )) && evButton == 0) || evType == "mousemove" || evType == "mouseup") { evt.preventDefault(); // prevents tripping the context-menu evt.stopPropagation(); // prevents launching hyperlinks evt.preventBubble(); // ditto ? evt.preventCapture(); // double-ditto ? // if we didn't doubleclick if ((evType == "click" || evType == "mousedown") && evCount < 2) return; if (evType == "mouseup") { window.document.removeEventListener("mousemove", adblockQuickblock, true); window.document.removeEventListener("mouseup", adblockQuickblock, true); return; } // ignore further movement, after cancelling if (evType != "click" && evType != "dblclick") { if (evType == "mousedown" &! window.Quickdrag) { // if quickdrag isn't activated, make it so window._Quickdrag = true; window.document.addEventListener("mousemove", adblockQuickblock, true); window.document.addEventListener("mouseup", adblockQuickblock, true); } if (item.tagName) itemTag = item.tagName.toLowerCase(); else itemTag = item.nodeName.toLowerCase(); // background-image removal if (QuickblockBackground) adblockQuickBackground(item, itemTag); // element hiding adblockQuickElement(deepItem, item, itemTag); } } } } // removes background-images from an element and all parent-table elements above it // -- for quickblock function adblockQuickBackground(item, itemTag) { var itemTest, tableItem, tableItemLast, tableChildRe, tableRe; var parentNode1 = false, parentNode2 = false, parentNode3 = false; var domDocNode = Components.interfaces.nsIDOMNode.DOCUMENT_NODE; tableChildRe = /td|tr/; itemTest = tableChildRe.test(itemTag); if (!itemTest && item.parentNode) { // failed; if there's a parent /* parentNode1 = tableChildRe.test(item.parentNode); if (!parentNode1 && item.parentNode.parentNode) { // failed; if there's a grandparent parentNode2 = tableChildRe.test(item.parentNode.parentNode); if (!parentNode2 && item.parentNode.parentNode.parentNode) parentNode3 = tableChildRe.test(item.parentNode.parentNode.parentNode); //failed; if there's a great-grandparent } */ } if ((itemTest || parentNode1 || parentNode2 || parentNode3) && (item.nodeType != domDocNode)) { tableItemLast = item, tableItem = item; tableRe = new RegExp("table"); while ( ! tableRe.test(tableItemLast.nodeName.toLowerCase())) { // crawl to the tabletop :P //tableItem.setAttribute("QuickblockTableBackground", document.defaultView.getComputedStyle(tableItem, null).getPropertyValue("background-image")); tableItem.style.setProperty("background-image", "none", "important"); // kill parent-tableitem's background-image if (tableItem.hasAttribute("background")) tableItem.removeAttribute("background"); if (!tableItem.parentNode || tableItem.parentNode.nodeType == domDocNode) break; tableItemLast = tableItem, tableItem = tableItem.parentNode; } // kill parent-table's parent-container background-image (*whew*) tableItem.style.setProperty("background-image", "none", "important"); if (tableItem.hasAttribute("background")) tableItem.removeAttribute("background"); } else { //if (document.defaultView.getComputedStyle(item, null).backgroundImage != "none") // <- fails item.style.setProperty("background-image", "none", "important"); // kill parent-table-container's background-image if (item.hasAttribute("background")) item.removeAttribute("background"); } } // quick-hides an element function adblockQuickElement(deepItem, item, itemTag) { var tagRe; if (itemTag == "area") { disableMapArea(item); // let adblock handle area-maps.. return; // ..don't continue } tagRe = new RegExp("table|tbody|tr|td|div|span|form|body|html|ul|ol|dl"); // ,"i" to make case-insensitive -- removed for speed if ( ! tagRe.test(itemTag)) { // don't hide block elements.. item.style.visibility = "hidden"; } else { // ..rather, hide what they contain if (item != deepItem) { // if there's a deeper node (usually text) if (deepItem.setAttribute) { deepItem.style.visibility = "hidden"; // hide directly, if possible } else // text has no setAttribute-method.. deepItem.parentNode.style.setProperty("visibility", "hidden", "important"); // ..so hide the parent } } } // toggles the object-override -- ("flashblocking") function toggleObjectOverride(wnd,force,reload) { var page = (wnd) ? wnd.document : document.getElementById("content").contentDocument; var pageElement = page.documentElement; var flashblockPosition; try { if (typeof(page.oncontextmenu) != 'undefined') delete page.oncontextmenu; // <- thehulk.com :P } catch (e) {} //doesn't seem to work under Fx 1.5 var wasActive = null; if (pageElement) { // no documentElement == no flashblock wasActive = (pageElement.hasAttribute("AdblockFlashblocked")); if (wasActive && (!force||reload)) { objectRemoveOverride(page); // removes all overrides registered in the global array flashblockPosition = pageElement.getAttribute("flashblockPosition"); page.documentElement._flashblockOverlayArray = null; // remove our tracking array -- securityManager prevents direct deletion page.removeEventListener("unload",objectRemoveOverride,true); //delete page.onunload; - causes error under Fx 1.5 pageElement.removeAttribute("AdblockFlashblocked"); var deactivated = true; } if ((!wasActive || (deactivated && reload)) && force!=false) { pageElement.setAttribute("AdblockFlashblocked", true); // tags the page as "flashblocked" :) //page.onunload = "objectRemoveOverride(this)"; // unloads flashblock on page-close -- so the global hashtable doesn't fill up page.addEventListener("unload",objectRemoveOverride,true); page.documentElement._flashblockOverlayArray = []; objCheckFrames(page, "override"); // checks frames -- adds the overrides } } return wasActive; } // catches all frames / iframes for object-overriding -- requires a page/element function objCheckFrames(page, conditional) { var itemFrames = page.getElementsByTagName("frame"); var itemiFrames = page.getElementsByTagName("iframe"); var frame, iframe; if (itemFrames.length > 0) for (var f = 0 ; f < itemFrames.length ; f++) { frame = itemFrames[f].contentDocument; objCheckFrames(frame, conditional); // recursion for frames } if (itemiFrames.length > 0) for (var g = 0 ; g < itemiFrames.length ; g++) { iframe = itemiFrames[g].contentDocument; objCheckFrames(iframe, conditional); // recursion for iframes } // if we have a valid page, override it if (page.hasChildNodes() && page.defaultView) switch (conditional) { case "override": //alert("overriding"); objectOverride(page); // check the page itself break; /* // DEPRECATED: this whole switch is unneeded now case "remove": //alert("removing"); objectRemoveOverride(page); break; */ } } // overlays all object's / embeds with a configurable div -- requires a page/element // -- overrides their "native" menus function objectOverride(page) { var rawObjects = page.getElementsByTagName("object"); var objects = new Array(); var objectEmbeds = new Array(); var rawEmbeds = page.getElementsByTagName("embed"); var embeds = new Array(); var applets = page.getElementsByTagName("applet"); var possibleTags = ["objects", "object-embeds", "embeds", "applets"]; var itemArray = new Array(); var childDiv, childDivTitle; var childTable, childTableRow, childTableData, childSpan; var x, y; var currentOffset, topmostFrame, flashblockPosition; // if we're in a frame/iframe, we'll need to get the flashblockPosition from our base document if (page.defaultView.frameElement) { topmostFrame = page.defaultView.frameElement; // break out of nested frames/iframes while (topmostFrame.ownerDocument.defaultView.frameElement) topmostFrame = topmostFrame.ownerDocument.defaultView.frameElement; flashblockPosition = topmostFrame.ownerDocument.documentElement.getAttribute("flashblockPosition"); } var flashblockOverlayArray = (page.documentElement._flashblockOverlayArray||(page.documentElement._flashblockOverlayArray=[])); // for each object, get its child-embed (if it has one), since only this carries correct width / height attributes for (var t = 0; t < rawObjects.length ; t++) { var children = rawObjects[t].getElementsByTagName("embed"); if (children.length > 0) for (var c = 0; c < children.length; c++) objectEmbeds.push(children[c]); // add child to our embed-array else objects.push(rawObjects[t]); // assume it's blockable if there's no child-embed } // check that our embed-list doesn't contain duplicates of *OBJECT-embeds* -- (we *should* just 'pop' the array, yo) for (var s = 0; s < rawEmbeds.length ; s++) { // fail-safe check for parentnode -- shouldn't ever fail if (rawEmbeds[s].parentNode) if (rawEmbeds[s].parentNode.tagName.toLowerCase() != "object") embeds.push(rawEmbeds[s]); // add any non-Object-embeds to our "accepted" array } // creates and adds the div-overlays for objects and raw-embeds for (var u = 0 ; u < possibleTags.length ; u++) { switch (possibleTags[u]) { case "objects": itemArray = objects; childDivTitle = "AdblockObjectDiv"; break; case "object-embeds": itemArray = objectEmbeds; childDivTitle = "AdblockObjectDiv"; break; case "embeds": itemArray = embeds; childDivTitle = "AdblockEmbedDiv"; break; case "applets": itemArray = applets; childDivTitle = "AdblockAppletDiv"; break; } for (var w = 0 ; w < itemArray.length; w++) if (itemArray[w] != null && itemArray[w].style.display != "none" && itemArray[w].style.visibility != "hidden") { x = itemArray[w].offsetLeft; y = itemArray[w].offsetTop; // if the item is contained by parent elements, add their position in too currentOffset = itemArray[w]; while (currentOffset.offsetParent) { var style = page.defaultView.getComputedStyle(currentOffset.offsetParent, null), isStatic=false; try{isStatic = style.getPropertyValue('position') == 'static';}catch(e){} if (isStatic) { x += currentOffset.offsetParent.offsetLeft; y += currentOffset.offsetParent.offsetTop; } currentOffset = currentOffset.offsetParent; // increment the conditional, for while-loop } //var nodeWrap = {node:null}; //getNodeURL(itemArray[w],nodeWrap); //if (nodeWrap.node) itemArray[w] = nodeWrap.node; if (itemArray[w].previousSibling && itemArray[w].previousSibling.attributes && ( itemArray[w].previousSibling.hasAttribute("AdblockObjectDiv") || itemArray[w].previousSibling.hasAttribute("AdblockEmbedDiv") || itemArray[w].previousSibling.hasAttribute("AdblockAppletDiv") ) ) childDiv = itemArray[w].previousSibling; // we already had an overlay-div else { childDiv = page.createElement("div"); // create our div-overlay childDiv.innerHTML = '
Flashblock
'; childDiv.setAttribute("width", itemArray[w].offsetWidth + "px"); childDiv.setAttribute("height", itemArray[w].offsetHeight + "px"); childDiv.setAttribute("style", "display: block; overflow: hidden; text-overflow: elipsis; background-color: #FFDFBF; border-color: #999999; border-width: 1px; border-style: solid; position: absolute; width: " + itemArray[w].offsetWidth + "px; height: " + itemArray[w].offsetHeight + "px; left: " + x + "px; top: " + y + "px; z-index: 900; visibility: visible;"); childDiv.setAttribute(childDivTitle, true); childDiv.addEventListener("click", onOverlayClick, true); childDiv._AdblockObject = itemArray[w]; /* * we're now dealing with child-embeds individually */ itemArray[w]._AdblockOverlay = childDiv; itemArray[w].style.visibility = "hidden"; // hide the embedded item itemArray[w].parentNode.insertBefore(childDiv, itemArray[w]); // append our overlay flashblockOverlayArray.push(childDiv); // the global pointer, so we can remove *all* overlays later -- stupid abcnews.com var objTab = itemArray[w]._AdblockFrame; if (objTab) objTab.style.visibility = "hidden"; //adblockPrefObserver.log("objTab: "+objTab); } } } } // removes the div-overlay for all objects / embeds function objectRemoveOverride(page) { if (!page) page = this; if (!page.defaultView) return; var flashblockPosition; var flashblockedItem; var parentNode; // if we're in a frame/iframe, we'll need to get the flashblockPosition from our base document if (page.defaultView.frameElement) { var topmostFrame = page.defaultView.frameElement; while (topmostFrame.ownerDocument.defaultView.frameElement) topmostFrame = topmostFrame.ownerDocument.defaultView.frameElement; flashblockPosition = topmostFrame.ownerDocument.documentElement.getAttribute("flashblockPosition"); } var flashblockOverlayArray = page.documentElement._flashblockOverlayArray if (!flashblockOverlayArray) return; var divOverlays = flashblockOverlayArray; for (var u = 0 ; u < divOverlays.length ; u++) { if (divOverlays[u].parentNode) parentNode = divOverlays[u].parentNode; else parentNode = divOverlays[u].ownerDocument; flashblockedItem = divOverlays[u]._AdblockObject||divOverlays[u].nextSibling; //adblockPrefObserver.log("divOverlays[u]._AdblockObject: "+divOverlays[u]._AdblockObject); parentNode.removeChild(divOverlays[u]); // <- don't remove until *after* we get it's 'nextSibling' -- duh! flashblockedItem.style.visibility = "visible"; //flashblockedItem.style.MozOutline = "red solid 1px"; //flashblockedItem.style.MozOutline = ""; //setTimeout(adblockRemovalCallback, 100, flashblockedItem); // maybe flash will repaint proper, now? var objTab = flashblockedItem._AdblockFrame; if (objTab) objTab.style.visibility = "visible"; } } //function adblockRemovalCallback(node) { node.style.visibility = "visible"; node.style.MozOutline = "#AB0000 dotted 2px !important"; } // Event handler, Flashblock-Overlay has been clicked function onOverlayClick(event) { var target = event.target; // break out of the overlay and get our target while (target.nodeName.toLowerCase() != "div") target = target.parentNode; target = target.nextSibling; itemFilterDialog(false, target); } // reveals context menu-items as needed function adblockSetContext(evt) { if (evt.target.id != "contentAreaContextMenu") return; var target = gContextMenu.target; //var menuSeparator = document.getElementById("adblock-separator-menuitem"); //var propertyMenuItem = document.getElementById("context-metadata"); // 'Properties' element-id under mozilla 1.3.1 var frameFilter = document.getElementById("adblock-iframe-menuitem"); var frameLevel = 0; // iframe depth-counter var topmostFrame = target.ownerDocument.defaultView.frameElement; if (topmostFrame) if (topmostFrame.nodeName.toLowerCase() == "iframe") { frameLevel = 1; // depth-counter -- begins with current while (topmostFrame.ownerDocument.defaultView.frameElement) { topmostFrame = topmostFrame.ownerDocument.defaultView.frameElement; if (topmostFrame.tagName.toLowerCase() == "iframe") frameLevel++; // only for iframes, increment the counter -- we crawl up all frames } if (frameLevel > 1) frameFilter.label = "Adblock iFrame (" + frameLevel + " deep)"; else frameFilter.label = "Adblock iFrame"; } // page-selection import var headerRe = /^[\s\r\n]*\[ ?Ad[Bb]lock ?\]/; try{ var isTxtFile = /\.txt$/.test(target.ownerDocument.location+'') || "text/plain"==target.ownerDocument.contentType; // /(^|[^a-zA-Z])text([^a-zA-Z]|$)/i.test(target.ownerDocument.contentType); if (isTxtFile) selection = target.ownerDocument.body.innerHTML, importable = headerRe.test(selection); }catch(e){} if (!importable) { // && gContextMenu.isTextSelected) { var selection = adblockGetSelection(); var importable = (selection.length > 0 && headerRe.test(selection)); } adblockCachedImportable = (importable) ? selection : ""; // reveal relevant item(s) gContextMenu.showItem('adblock-import-menuitem' , (importable)); gContextMenu.showItem('adblock-iframe-menuitem' , (frameLevel > 0)); gContextMenu.showItem('adblock-image-menuitem' , (gContextMenu.onImage && !gContextMenu.onStandaloneImage)); gContextMenu.showItem('adblock-maparea-menuitem', (target.nodeName.toLowerCase() == "area")); gContextMenu.showItem('adblock-object-menuitem' , (target.hasAttribute && target.hasAttribute("AdblockObjectDiv") )); gContextMenu.showItem('adblock-embed-menuitem' , (target.hasAttribute && target.hasAttribute("AdblockEmbedDiv") )); gContextMenu.showItem('adblock-applet-menuitem' , (target.hasAttribute && target.hasAttribute("AdblockAppletDiv") )); gContextMenu.showItem('adblock-background-menuitem', (gContextMenu.hasBGImage && !gContextMenu.onImage)); } var adblockCachedImportable = ""; function adblockImportSelected() { var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); observerService.notifyObservers(null, "Adblock-ImportFilters", adblockCachedImportable); //selection); adblockCachedImportable = ""; } function adblockGetSelection() { var node = document.popupNode; // the element our context-popup is targeting (same as target) var selection = "", shouldCoerce=true; var nodeLocalName = node.localName.toLowerCase(); if ((nodeLocalName == "textarea") || (nodeLocalName == "input" && (node.type == "text" || node.type == "password"))) selection = node.value.substring(node.selectionStart, node.selectionEnd); else if (nodeLocalName == "option") { var parentSelect = node.parentNode; if (parentSelect.localName.toLowerCase() == "select") { if (parentSelect.multiple) for (var i = 0; i < parentSelect.options.length; i++) { if (parentSelect.options[i].selected) selection += " " + parentSelect.options[i].value; } else selection = node.value; } } else if (nodeLocalName == "select") selection = node.options[node.selected].value; else { selection = document.commandDispatcher.focusedWindow.getSelection(); // sorry- we'll have to require that the user actually right-click ON the selection // -- there doesn't seem any way to discover the selected-node that isn't ALWAYS .nodeName:#text (the underlying text) if (node.nodeName.toLowerCase() == "#text") // text-nodes don't pass their newlines / breaks to getSelection() selection = selection.getRangeAt(0).cloneContents().firstChild.nodeValue, shouldCoerce = false; } if (shouldCoerce) selection = ""+selection; // coercing the .nodeValue via .toString (as method) strips linebreaks if (selection=="") try{ var doc = node.ownerDocument, range = doc.createRange(); range.selectNodeContents(node); selection = range.toString(); }catch(e){} return selection; } // disables a map-area, so we can click on the content beneath it function disableMapArea(areaItem) { if (adblockPrefObserver.isPendingCallback) return adblockPrefObserver.isPendingCallback(); if (!areaItem) areaItem = gContextMenu.target; areaItem.setAttribute("AdblockDisabled", true); if (areaItem.hasAttribute("coords")) { areaItem.setAttribute("AdblockCoords", areaItem.getAttribute("coords")); areaItem.removeAttribute("coords"); } //areaItem.style.display = "none"; // UNNEEDED: this has the side-effect of hiding items underneath -- removing the 'coords' is enough } // get the target node for an overlay function getOverlayTarget(target) { while (target.nodeName.toLowerCase() != "div") target = target.parentNode; target = target.nextSibling; return target; } // pops a filter dialog on right-click function itemFilterDialog(isFrame, targetNode) { if (adblockPrefObserver.isPendingCallback) return adblockPrefObserver.isPendingCallback(); if (typeof(targetNode) != 'undefined' && targetNode) var node = targetNode; else node = gContextMenu.target._AdblockObject||gContextMenu.target; // make sure we get the frame-node, if it's a frame // if the target is a frame / iframe if (typeof(isFrame) != 'undefined' && isFrame) node = node.ownerDocument.defaultView.frameElement; var page = node.ownerDocument; // -ownerDocument -! (ps: iframes don't register a parentNode from within them) // passes the target item to the dialogue via window.argument[1] -- allows the item to be refiltered on 'accept' //var nodeWrap = {node:null}; var dialogHandle = window.openDialog("chrome://adblock/content/addfilterdialog.xul","Add filter", "chrome,modal,centerscreen", getNodeURL(node/*,nodeWrap*/), node/*Wrap.node*/); } function imgFilterDialog(isBackground) { if (adblockPrefObserver.isPendingCallback) return adblockPrefObserver.isPendingCallback(); var imgURL = (isBackground) ? gContextMenu.bgImageURL : gContextMenu.imageURL; window.openDialog("chrome://adblock/content/addfilterdialog.xul","Add filter", "chrome,modal,centerscreen", imgURL, gContextMenu.target); } function getNodeURL(node,nodeWrap) { //var wnd = document.getElementById("content").contentDocument.defaultView.top; var wnd = node.ownerDocument.defaultView.top; var data = wnd.document._Adblock; for (var i in data) for (var j=0; j PK -4뎴##ycontent/adblock.xulSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT VDDD PK -4;+ttycontent/addfilterdialog.jsSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT VDDD/* ** GPL Licensed, by: Henrik, Wladimir, rue */ // user clicked "OK", so save the pattern and 'live-filter' the target item function doOK(item) { var textbox = document.getElementById("tbox"); var pat; if (textbox.value.charAt(0) == "@" && textbox.value.charAt(1) == "@") pat = textbox.value.substr(2,textbox.value.length-2); else pat=textbox.value; if (adblockIsRegExp(pat, true)) { if (!adblockWarnRegExp()) // if the user didn't want to enter a regular expression, cancel the "OK" return false; } addFilter(textbox.value); // save the filter to prefs if(item != "") { //var wnd = (item.ownerDocument?item.ownerDocument:item).defaultView.top; var doc = item.ownerDocument?item.ownerDocument:item; var wnd = window.arguments[2] || doc.defaultView.top; refilter(wnd); // refilter page } return true; } // user clicked "Cancel", so close out function doCancel() { return true; } // set the input-field to the target item's source function initDialog() { var textelement = document.getElementById("tbox"); textelement.setAttribute("value", window.arguments[0]); } PK -4 PK .4UCI I ycontent/filterall.cssSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT XDDD/* http://xulplanet.com/tutorials/xultu/treestyle.html */ treechildren:-moz-tree-cell-text(filtered) { color: #993333; font-style: italic; } treechildren:-moz-tree-cell-text(filtered, selected) { color: #440000 !important; } treechildren:-moz-tree-cell-text(white) { color: #333399; } treechildren:-moz-tree-cell-text(white, selected) { color: #000099 !important; } treechildren:-moz-tree-cell-text(unfiltered) {} [whitelisted="true"] *, treechildren.whitelistedNonMutable, /* ..so already-filtered content keeps showing white, even if whitelisting is toggled off */ treechildren.whitelistedNonMutable:-moz-tree-cell-text(selected), treechildren.whitelisted, treechildren.whitelisted:-moz-tree-cell-text(filtered), treechildren.whitelisted:-moz-tree-cell-text(filtered, selected), treechildren.whitelisted:-moz-tree-cell-text(white), treechildren.whitelisted:-moz-tree-cell-text(white, selected), treechildren.whitelisted:-moz-tree-cell-text(unfiltered) { color: #333399 !important; } /* from settings.css, for the Add button */ checkbox, radio, button, toolbarbutton { cursor: pointer !important; } toolbarbutton { border-style: none !important; } toolbarbutton[id="newbutton"], toolbarbutton[id="newbutton"]:hover { border-style: none !important; /*-moz-outline: 2px groove #BB9999 !important;*/ font-style: italic !important; color: #663333 !important; } toolbarbutton[id="newbutton"] label { /*visibility: hidden !important;*/ } toolbarbutton[id="newbutton"]:hover label { visibility: visible !important; font-style: italic !important; color: #663333 !important; } /* checkbox[id="whitelist-checkbox"], checkbox[id="whitelist-checkbox"] * label { border-right-style: none !important; padding-right: 0 !important; margin-right: 0 !important; } */ checkbox[id="whitelist-checkbox"], checkbox[id="whitelist-checkbox"] *, menulist[id="whitelist-menu"] { padding-bottom: 0 !important; padding-top: 0 !important; margin-bottom: 0 !important; margin-top: 0 !important; } menulist[id="whitelist-menu"], menulist[id="whitelist-menu"] * { /*xborder-left-style: none !important;*/ padding-left: 0 !important; margin-left: 0 !important; } .translucent { -moz-opacity: 0.4; opacity: 0.4; } hbox:hover > .translucent { -moz-opacity: 0.99; opacity: 0.99; } hbox:hover > .translucent * { -moz-opacity: 1.0; opacity: 1.0; } PK .40=e@e@ycontent/filterall.jsSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT XDDD/* ** GPL Licensed, by: Henrik, rue */ const DATASOURCE_CONTRACTID = '@mozilla.org/rdf/datasource;1?name=in-memory-datasource'; const RDFSERVICE_CONTRACTID = '@mozilla.org/rdf/rdf-service;1'; const CONTAINERUTILS_CONTRACTID = '@mozilla.org/rdf/container-utils;1'; const CONTENTPOLICY_CONTRACTID = "@mozilla.org/layout/content-policy;1"; var rdf = Components.classes[RDFSERVICE_CONTRACTID].getService(Components.interfaces.nsIRDFService); var utils = Components.classes[CONTAINERUTILS_CONTRACTID].getService(Components.interfaces.nsIRDFContainerUtils); var policy = Components.classes[CONTENTPOLICY_CONTRACTID].getService(Components.interfaces.nsIContentPolicy); var datasource, sequence; const prefix = 'http://adblock.mozilla.org/rdf#'; var console = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService); function log(msg) { console.logStringMessage(msg); } var nodes = {}; var nodeTypes = {}; var appShell = Components.classes["@mozilla.org/appshell/appShellService;1"].getService(Components.interfaces.nsIAppShellService); var hiddenWnd = appShell.hiddenDOMWindow; // global hidden-window var apiConstants = hiddenWnd.apiConstants; var isBlocked = hiddenWnd.isBlocked; var isWhite = hiddenWnd.isWhite; var addWhite = hiddenWnd.addWhite; var storeAdblockData = hiddenWnd.storeAdblockData; var whiteKey = hiddenWnd.whiteKey; var treeConstants = new Object(); // the tree-object changed, per bug 221619 -- this will hold our "api-switch" bool var typeDescr = []; typeDescr[apiConstants.SCRIPT] = 'SCRIPT'; typeDescr[apiConstants.IMAGE] = 'IMAGE'; typeDescr[apiConstants.SUBDOCUMENT] = 'SUBDOCUMENT'; typeDescr[apiConstants.OBJECT] = 'OBJECT'; typeDescr[apiConstants.DOCUMENT] = 'DOCUMENT'; typeDescr[apiConstants.XMLHTTPREQUEST] = 'AJAX'; var flasher = { url: null, loopCount: 0, minorCount: 0, hiddenCount: 0, timeout: null, origOutline: [], flash: function(url) { this.stop(); this.url = url; this.loopCount = 0; this.minorCount = 0; this.hiddenCount = 0; this.doFlash(); }, doFlash: function() { // if we've looped the max-times, stop if ( ! (this.loopCount < 3)) { this.switchOff(); this.url = null; return; } // If we're still visible-flashing if (this.minorCount < 12) { if (this.minorCount % 2) this.switchOff(); else this.switchOn(); this.minorCount++; } // ..or we've flashed our visible-limit else { // ..and we're still hidden-flashing if (this.hiddenCount < 6) this.hiddenCount++; // ..otherwise, we've flashed our hidden-limit else { this.loopCount++; this.minorCount = 0; this.hiddenCount = 0; } } this.timeout = setTimeout('flasher.doFlash()', 120); }, stop: function() { if (this.url != null) { clearTimeout(this.timeout); this.switchOff(); } }, switchOn: function() { var list = nodes[this.url]; for (var i=0; i 0 ) node = node.contentDocument.getElementsByTagName('body')[0]; //this.origOutline[String(i)] = node.style.MozOutline; if (node.style) node.style.MozOutline = "#AB0000 dotted 2px !important"; } }, switchOff: function() { var list = nodes[this.url]; for (var i=0; i 0 ) node = node.contentDocument.getElementsByTagName('body')[0]; //node.style.MozOutline = this.origOutline[String(i)] ? this.origOutline[String(i)] : 'none'; if (node.style) node.style.MozOutline = 'none'; } } }; // if the user clicks "OK", saves the filter and refilters the document function allOK() { var filterAccepted = tryToAddFilter(); if(!filterAccepted) return false; // don't stop filter if the user cancels the addition updateWhitelist(); flasher.stop(); return true; } var url, initialWhiteType=null; function setupWhitelist(wnd) { url = wnd.location+""; var whiteType = initialWhiteType = isWhite(url); var whiteActive = (whiteType==null) ? false:true; if (whiteActive) document.getElementById("whitelist-menu").selectedIndex = whiteType; document.getElementById("whitelist-menu").removeAttribute('sizetopopup'); // since moz1.3.1 overrides our xul on this - document.getElementById("whitelist-checkbox").setAttribute("checked", whiteActive); var c = document.getElementById("whitelist-container"); /*if (!c.hasAttribute('style'))*/ { var cHeight = window.getComputedStyle(c, null).getPropertyValue('height'); c.setAttribute('style', "min-height: "+cHeight+" !important;"); } document.getElementById("whitelist-checkbox").doCommand(); if (wnd.document[whiteKey]) document.getElementById("adblock-treechildren").setAttribute('class','whitelistedNonMutable') } function updateWhitelist() { var whiteType = currentWhiteType(); // our current setting var stuff = [url,whiteType].join(" "); addWhite(stuff); } function currentWhiteType() { var checkValue = document.getElementById("whitelist-checkbox").getAttribute("checked"); var whiteActive = (checkValue == "true") ? true:false; var whiteType = whiteActive ? document.getElementById("whitelist-menu").value : "null"; return whiteType; } function whiteCheckboxCommand(item) { var checked = (item.getAttribute('checked')=='true'); var p = item.parentNode.parentNode; p.setAttribute('class',checked?'nontranslucent':'translucent'); var m = document.getElementById('whitelist-menu'); m.disabled = !checked; m.setAttribute('style',(checked?' ':'display:none')); //m.setAttribute('style',(checked?'visibility:visible':'visibility:hidden;width:0;max-width:0;padding-left:0;padding-right:0;margin-left:0;margin-right:0;border-left-style:none;border-right-style:none;')); if (checked) { var mp = m.parentNode; mp.removeChild(m), mp.appendChild(m); } if (m.hasAttribute('sizetopopup')) m.removeAttribute('sizetopopup'); var r = document.getElementById('root-vbox'); checked ? r.setAttribute('whitelisted',true) : r.removeAttribute('whitelisted'); var t = document.getElementById('adblock-treechildren'); if (!t.hasAttribute('class')||t.getAttribute('class')!='whitelistedNonMutable') checked ? t.setAttribute('class','whitelisted') : t.removeAttribute('class'); document.getElementById('references-tree').treeBoxObject.clearStyleAndImageCaches(); var textbox = document.getElementById("filter"); var tree = document.getElementById('references-tree'); treeConstants.oldStyleAPI ? tree.treeBoxObject.selection.clearSelection() : tree.treeBoxObject.view.selection.clearSelection(); textbox.value = ""; textbox.disabled = false; } function whiteMenuClick(item) { var c = document.getElementById('whitelist-checkbox'); if (c.getAttribute('checked') != 'true') c.setAttribute('checked', true), c.doCommand(); /*, item.open=true;*/ } function tryToAddFilter() { var textbox = document.getElementById("filter"); if (!textbox.disabled) { // only if an already-filtered item wasn't selected var pattern = textbox.value; if (pattern.charAt(0) == "/" && pattern.charAt(pattern.length - 1) == "/" && !adblockWarnRegExp()) return false; // if the user didn't want to enter a regular expression, cancel the "OK" var emptyRe = /^\s*$/; if (pattern == null || emptyRe.test(pattern)) return true; // don't add null filter addFilter(pattern); // save the filter to prefs var wnd = window.arguments[0]; refilter(wnd); // refilter the whole page -- we'll handle wnd.closed conditions during refiltering } return true; } function allCancel() { flasher.stop(); return true; } // fill the list with external references function init() { datasource = Components.classes[DATASOURCE_CONTRACTID].createInstance(Components.interfaces.nsIRDFDataSource); var tree = document.getElementById('references-tree'); tree.database.AddDataSource(datasource); sequence = utils.MakeSeq(datasource, rdf.GetResource('urn:root:references')); /* if (window.arguments[1]) addAllReferences(window.arguments[0].ownerDocument.defaultView.top); else addReferences(window.arguments[0]); */ var wnd = window.arguments[0]; setupWhitelist(wnd); addAllReferences(wnd); // get all items for current browser-page treeConstants.oldStyleAPI = (tree.treeBoxObject.selection ? true : false); // per bug 221619 (see above) treeConstants.oldStyleAPI ? tree.treeBoxObject.selection.clearSelection() //.select(null); //0) : tree.treeBoxObject.view.selection.clearSelection(); //.select(null); //0) if ('focus' in tree) tree.focus(); if ('clearStyleAndImageCaches' in tree.treeBoxObject) tree.treeBoxObject.clearStyleAndImageCaches(); // update treechildren styles, in case whitelisting was set (or odd column-alignment adjustment, under moz1.3.1 -- persistence?) } // on selection-change, show the item's url (if unfiltered), OR the filter that caught the item function onSelectionChange() { var textbox = document.getElementById('filter'); var tree = document.getElementById('references-tree'); var selection = treeConstants.oldStyleAPI ? tree.treeBoxObject.selection : tree.treeBoxObject.view.selection; var editButton = document.getElementById("edit-filter"); if (selection.count != 1 || !selection.isSelected(selection.currentIndex)) return (editButton.hidden=true); //Exception is thrown when called on about:blank page. try {var resource = tree.builderView.getResourceAtIndex(selection.currentIndex);} catch(e) {return;} var filter = datasource.GetTarget(resource, rdf.GetResource(prefix + 'filter'), true); if (filter) filter = filter.QueryInterface(Components.interfaces.nsIRDFLiteral); if (filter && filter.Value != "NoMatch") { filter = filter.Value.toString(); var simpleRe = /\(\?\:\\n\)\?/; // test for the "Adblock simple-filter" flag //var simpleRe = /(^\^http)|(\(ABsf\)\?\$\/\i$)/; // if the filter is simple, de-RegExp -- otherwise, get the pattern sans-delimiters if (simpleRe.test(filter)) filter = filter.replace(/^(\@\@)?\/(.*)\(\?\:\\n\)\?\/i?$/, "$1$2").replace(/\\\./g, " ").replace(/\.\*/g, "*").replace(/ /g, ".").replace(/\\/g, ""); // first 'replace' is same as substr, below -- left regexp for fun else filter = filter.substr(0, filter.length - 1); // length isn't zero-based + / + $ + flag "i" are anchored to end if (!textbox.disabled) textbox.disabled = true; textbox.value = filter; editButton.hidden=false; flasher.stop(); } else { var url = datasource.GetTarget(resource, rdf.GetResource(prefix + 'url'), true); if (url) url = url.QueryInterface(Components.interfaces.nsIRDFLiteral); if (url) { if (textbox.disabled) textbox.disabled = false; textbox.value = url.Value; editButton.hidden=true; flasher.flash(url.Value); } } } function addNodeReferences(data) { var url = data.contentLocation.spec; var filterMatch = data.filterMatch; var node = data.node; var type = data.contentType; if (!filterMatch) { if (initialWhiteType==null) var displayStyle = "unfiltered"; else displayStyle = "white"; } else if (filterMatch.white) displayStyle = "white", filterMatch = filterMatch.asWhiteString; else displayStyle = "filtered"; if (typeof(nodes[url]) == 'undefined') { nodes[url] = []; nodeTypes[url] = []; var resource = rdf.GetResource(url); datasource.Assert(resource, rdf.GetResource(prefix + 'url'), rdf.GetLiteral(url), true); datasource.Assert(resource, rdf.GetResource(prefix + 'type'), rdf.GetLiteral(typeDescr[type].toLowerCase()), true); datasource.Assert(resource, rdf.GetResource(prefix + 'elements'), rdf.GetLiteral(''), true); datasource.Assert(resource, rdf.GetResource(prefix + 'displaystyle'), rdf.GetLiteral(displayStyle), true); datasource.Assert(resource, rdf.GetResource(prefix + 'filter'), rdf.GetLiteral(filterMatch ? filterMatch : "NoMatch"), true); sequence.AppendElement(resource); } for (var i=0; i node: '+node[i]+' , url: '+url); continue; } var found = false; var types = nodeTypes[url]; for (var j=0; j\nwnd: "+wnd+"\ndocument: "+wnd.document+"\n _Adblock: "+wnd.document._Adblock); if (!data) eval("data=wnd.document._Adblock;"); if (!data) return; for (var i in data) addNodeReferences(data[i]); } // adds the filter to prefs function addFilter(filter) { if (filter != "") { var wPatterns = null; try { var prefObj = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); var Branch = prefObj.getBranch("adblock."); wPatterns = Branch.prefHasUserValue("patterns") ? Branch.getCharPref("patterns") : null; } catch(e) {} if (wPatterns) wPatterns += " " + filter; else wPatterns = filter; try { Branch.setCharPref("patterns", wPatterns); //prefObj.savePrefFile(null); // save the prefs to disk -- component.js "loadSettings()" handles this now var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); observerService.notifyObservers(null, "Adblock-PrefChange", "FilterChange"); observerService.notifyObservers(null, "Adblock-SavePrefFile", null); } catch(e) {} } } // refilters all nodes of a window function refilter(wnd) { var wasActive = opener.toggleObjectOverride(wnd,false); var doc = wnd.document; var data = /*wnd._Adblock||*/doc._Adblock||{}; try{ doc[whiteKey] = (currentWhiteType()!='null') ? true:false; }catch(e){} //if (doc._Adblock) doc._Adblock=null; // XXX since the ordering in the obj is maintained, we can actually leave this // we flush the data below -- delete data[i] var i, node, contentType, contentLocation; for (i in data) { if (wnd.closed) return; // note: this is *inside the loop -- the window might be closed, mid-run node = data[i].node; contentType = data[i].contentType; contentLocation = data[i].contentLocation; delete data[i]; if (contentType == apiConstants.XMLHTTPREQUEST) { for (var k=0; k PK .4<6ycontent/global.jsSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT XDDDvar __abCancelled; var __abWarn; var console = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService); // Checks if a filter is already a regular expression. if warn is true, // the user is warned. function adblockIsRegExp(filter, warn) { if (filter.charAt(0) == "/" && filter.charAt( filter.length - 1) == "/") { return true; } else { return false; } } // Warns the user that he has entered a regular expression. // Returns true if the user is ok with this, false if he wants to change the filter. function adblockWarnRegExp() { var Branch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("adblock."); var warnregexp = Branch.getBoolPref("warnregexp"); if (!warnregexp) return true; var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); var check = {value: false}; var result = prompts.confirmCheck(window, "Warning", "The filter you entered will be interpreted as a regular expression.\ If you did not mean for this to happen, or don't know what a regular expression is,\ press cancel and remove / from the edges of the filter.", "I know what I'm doing. Don't warn me in the future.", check); Branch.setBoolPref("warnregexp", !check.value); return result; } PK .4H.ycontent/lockup.htmlSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT XDDD
Adblock
PK /4(cggycontent/nsAdblock-extras.jsSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT YDDD/* ** authored by rue */ function wrapToImplicit(requestingNode, implicitWrap, contentType) { var requestingNodeUnwrapped = requestingNode; var forceWrap = (contentType==apiConstants.OBJECT); try { requestingNode = adblockWrap(requestingNode, forceWrap, 'defaultView','top','contentWindow','ownerDocument'); }catch(e) { /*throw(e);*/ } var domWnd = requestingNode.defaultView || (requestingNode.localName=="browser"?requestingNode.contentWindow:null) || (requestingNode.ownerDocument ? requestingNode.ownerDocument.defaultView : null); if (!lastWindow||lastWindow.closed) lastWindow = windowMediator.getMostRecentWindow("navigator:browser"); var msg="" var newEvent = lastWindow.document.createEvent('MouseEvents'); newEvent.initMouseEvent('abCatchNode', true,true, domWnd, 1, 0,0,0,0, false,false,false,false, 1, requestingNodeUnwrapped); implicitWrap.wnd = newEvent.view; //msg+=("wnd: "+implicitWrap.wnd+" -> "+implicitWrap.wnd.testX); newEvent = lastWindow.document.createEvent('MutationEvents'); newEvent.initMutationEvent('abCatchNode3', true,true, implicitWrap.wnd.top.document, "a","b","c",1); implicitWrap.doc = newEvent.relatedNode; //msg+=("\ndoc: "+implicitWrap.doc+" -> "+implicitWrap.doc.testX); newEvent = lastWindow.document.createEvent('MutationEvents'); newEvent.initMutationEvent('abCatchNode2', true,true, requestingNodeUnwrapped, "a","b","c",1); implicitWrap.requestingNode = newEvent.relatedNode; //msg+=("\nrequestingNode: "+implicitWrap.requestingNode); //implicitWrap.doc.testM = implicitWrap.wnd.testM = 10; //log(msg); if (!implicitWrap.doc._Adblock) implicitWrap.doc._Adblock={"hey-nelly":true}; else log("._Adblock: already"); if (!implicitWrap.doc._AdblockFiltered) implicitWrap.doc._AdblockFiltered={"ho-nelly":true}; else log("._AdblockFiltered: already"); } function wrapToImplicit_Single(node) { var nodeUnwrapped = node; var newEvent = lastWindow.document.createEvent('MutationEvents'); newEvent.initMutationEvent('abCatchNode3', true,true, nodeUnwrapped, "a","b","c",1); node = newEvent.relatedNode; log("node: "+node); return node; } PK /40@ ycontent/settings.cssSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT YDDDhbox[id="buttonmenu-hbox"] { border-style: none !important; -moz-outline: 2px groove LightGray; padding: 2px 7px 3px 7px !important; margin: 0 2px 5px 0 !important; } hbox[id="buttonmenu-hbox"] > toolbarbutton, hbox[id="buttonmenu-hbox"] > toolbarbutton * { vertical-align: middle !important; text-align: middle !important; padding: 1px 1px 1px 1px !important; } hbox[id="buttonmenu-hbox"] > * { padding: 0 1px 0 1px !important; margin: 0 !important; } hbox[id="buttonmenu-hbox"] > toolbarbutton, hbox[id="buttonmenu-hbox"] > toolbarbutton * { border-style: none !important; /*xpadding: 0 !important;*/ margin: 0 !important; } textbox[id="li-tb-generated"] { margin: 0px 1px 0px 1px !important; margin-top: 0px !important; margin-bottom: 0px !important; padding: 0px 1px 0px 4px !important; padding-top: 0px !important; padding-bottom: 0px !important; /*xxborder-width: 1px 1px 1px 1px !important;*/ border-width: 0px !important; border-top-width: 0px !important; border-bottom-width: 0px !important; -moz-outline: #333333 solid 1px !important; } *[disabled="true"] { cursor: default !important; } checkbox, radio, button, toolbarbutton { cursor: pointer !important; } toolbarbutton { border-style: none !important; } toolbarbutton[id="newbutton"], toolbarbutton[id="newbutton"]:hover { border-style: none !important; /*x-moz-outline: 2px groove #BB9999 !important;*/ font-style: italic !important; color: #663333 !important; /* xpadding: 1px 2px 1px 0px !important; border-width: 2px !important; border-color: LightGray !important; border-style: groove inset inset none !important; -moz-border-top-colors: LightGray !important; -moz-border-right-colors: LightGray !important; -moz-border-bottom-colors: LightGray !important; -moz-border-left-colors: LightGray !important; xx-moz-border-radius-topright: 3pt !important; xx-moz-border-radius-bottomright: 3pt !important; xx-moz-outline: 2px ridge black !important; */ } toolbarbutton[id="newbutton"] label { /*xvisibility: hidden !important;*/ } toolbarbutton[id="newbutton"]:hover label { visibility: visible !important; font-style: italic !important; color: #663333 !important; } xxlistitem { border-width: 0px !important; } listbox-base { -moz-binding: url("settings.xml#listbox-base") !important;} listbox { -moz-binding: url("settings.xml#listbox") !important;} listrows { -moz-binding: url("settings.xml#listrows") !important;} listitem { -moz-binding: url("settings.xml#listitem") !important; border-width: 0px !important; } listitem-iconic { -moz-binding: url("settings.xml#listitem-iconic") !important;} listitem-checkbox { -moz-binding: url("settings.xml#listitem-checkbox") !important;} listitem-checkbox-iconic { -moz-binding: url("settings.xml#listitem-checkbox-iconic") !important;} listcell { -moz-binding: url("settings.xml#listcell-iconic") !important;} listcell-iconic { -moz-binding: url("settings.xml#listcell-iconic") !important;} listcell-checkbox { -moz-binding: url("settings.xml#listcell-checkbox") !important;} listcell-checkbox-iconic { -moz-binding: url("settings.xml#listcell-checkbox-iconic") !important;} listhead { -moz-binding: url("settings.xml#listhead") !important;} listheader { -moz-binding: url("settings.xml#listheader") !important;} PK /4@ycontent/settings.jsSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT YDDDvar sortFlag = 0; // global flag to discern if the user has already been told to "reload settings to activate sort" var popupBeingShownN = new Array(); // global node for button-menus popupBeingShownN[0] = false; // boolean: are we showing a button-menu -- "now" popupBeingShownN[1] = null; // the id of the button-menu showing now -- "currentItem" var restoreindexTimer; // calls restoreListIndex after a short delay when the list is created / updated var menuTimer; // deactivates the button-menu's after 15 seconds var buttonMenusLoaded = false; // global flag to discern if the button-menus have been called -- filter context-menu needs this // Loads preferences into the UI. function loadPrefWindow() { var Branch = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService).getBranch("adblock."); var boolType = Components.interfaces.nsIPrefBranch.PREF_BOOL, type="getPrefType", set="setBoolPref"; var charType = Components.interfaces.nsIPrefBranch.PREF_STRING; var Patterns = (Branch[type]("patterns" )==charType) ? Branch.getCharPref("patterns").split(" ") : null; var Enabled = !(Branch[type]("enabled" )==boolType) || Branch.getBoolPref("enabled"); // default:true var LinkCheck = (Branch[type]("linkcheck" )==boolType) && Branch.getBoolPref("linkcheck"); // default:false var PageBlock = (Branch[type]("pageblock" )==boolType) && Branch.getBoolPref("pageblock"); // default:false var Hide = (Branch[type]("hide" )==boolType) && Branch.getBoolPref("hide"); // default:false var FastCollapse = (Branch[type]("fastcollapse")==boolType) && Branch.getBoolPref("fastcollapse"); // default:false var FrameObjects = !(Branch[type]("frameobjects")==boolType) || Branch.getBoolPref("frameobjects"); // default:true var ListSort = (Branch[type]("listsort" )==boolType) && Branch.getBoolPref("listsort"); // default:false // load patterns into list var overwriteCurrentList = true; // always overwrite the current list if (Patterns != null && Patterns != "") fillList(Patterns, overwriteCurrentList, ListSort); //else document.getElementById("newfilter").focus(); // UNNEEDED: reSelectListItem does this -- empty-list returns focus to the textbox var enablebox = document.getElementById("enabled"); enablebox.checked = Enabled; var radiohide = document.getElementById("radio-hide"); var radioremove = document.getElementById("radio-remove"); radiohide.disabled = !enablebox.checked; radioremove.disabled = !enablebox.checked; if (Hide) radiohide.setAttribute("selected", true); else radioremove.setAttribute("selected", true); /* var collapsebox = document.getElementById("fastcollapse"); collapsebox.checked = FastCollapse; (document.getElementById('radio-remove').selected) ? document.getElementById('fastcollapse').setAttribute('style', 'visibility: visible') : document.getElementById('fastcollapse').setAttribute('style', 'visibility: hidden'); */ var listsortmenu = document.getElementById("listsort"); listsortmenu.setAttribute("checked", ListSort); var frameobjectsmenu = document.getElementById("frameobjects"); frameobjectsmenu.setAttribute("checked", FrameObjects); var slowcollapsemenu = document.getElementById("slowcollapse"); slowcollapsemenu.setAttribute("checked", !FastCollapse); // reverse-pref: fast -> slow var linkcheckmenu = document.getElementById("linkcheck"); linkcheckmenu.setAttribute("checked", LinkCheck); var pageblockmenu = document.getElementById("pageblock"); pageblockmenu.setAttribute("checked", PageBlock); window.setTimeout("restoreListIndex()", 0); // sets the list to the last-selected item, or the input-line if none //restoreListIndex(); } // Add a filter to the list -- now constructed for inline-editing :) function addFilter() { var newItem; var list = document.getElementById("list"); var textbox = document.getElementById("newfilter"); // if there's an actual entry if (textbox.value != "") { // if it's not a regular expression, or it is, BUT we've said 'ok' to the warning if (!adblockIsRegExp(textbox.value) || (adblockIsRegExp(textbox.value) && adblockWarnRegExp())) { var filter = makePattern(textbox.value); // must be made into pattern textbox.value = ""; var newItem = createListItem(filter); var newItemindex = list.getIndexOfItem(newItem); list.selectedIndex = newItemindex; // sets the list's selection to the new item list.currentItem = newItem; list.ensureIndexIsVisible(newItemindex); // scrolls the list to show the new item enableRevert(); } } //if (!textbox.focused) //textbox.focus(); // always return focus to the textbox } var listKeys = {}; function fillList(Patterns, overwriteCurrentList, listSortChecked) { var list = document.getElementById("list"); if (overwriteCurrentList && list.getRowCount() != 0) { // use instead for the disabled code -> && list.hasChildNodes()) { clearList(true); // clear the list, sans dialog } // Sort the patterns -- would *much* rather do this with a col-header [rue] if (listSortChecked) Patterns.sort(); // fill the list with patterns listKeys = {}; for (var i = 0; i < Patterns.length; i++) if (!/^[\s]*$/.test(Patterns[i])) listKeys[Patterns[i]] = createListItem(Patterns[i]); // only non-empty patterns! restoreindexTimer = setInterval('clearInterval(restoreindexTimer); restoreListIndex();',10); } // Asks the user if he really wants to clear the list. function clearList(dontConfirm) { if (!dontConfirm) if (!confirm("Do you really want to clear the list?")) return; var list = document.getElementById("list"); list.parentNode.replaceChild(list.cloneNode(false), list); // clear the list enableRevert(); } // Imports filters from web. function importListFromWeb() { var URI = Components.classes["@mozilla.org/network/simple-uri;1"].createInstance(Components.interfaces.nsIURI); try { URI.spec = 'http://www.eschew.org:80/filters.txt'; } catch(e) { console.logStringMessage(e.toString()); alert("oops"); } var IOService = Components.classes["@mozilla.org/network/io-service;1"].createInstance(Components.interfaces.nsIIOService); try { // var channel = IOService.newChannelFromURI( URI ); var channel = IOService.newChannel('http://www.eschew.org:80/filters.txt', null, null); } catch(e) { console.logStringMessage(URI.spec + e.toString()); } var stream = channel.open(); // This should be changed to async mode instead of sync if it doesn't work var streamIO = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); var overwriteCurrentList = false; var input, inputArray, linebreak; var validFile = false; streamIO.init(stream); input = streamIO.read(stream.available()); streamIO.close(); stream.close(); try { // now: unix + mac + dos environment-compatible linebreak = input.match(/(?:\[Ad[Bb]lock\])(((\n+)|(\r+))+)/m)[1]; // first: whole match -- second: backref-1 -- etc.. inputArray = input.split(linebreak); var headerRe = /\[Ad[Bb]lock\]/; // tests if the first line is adblock's header if (headerRe.test(inputArray[0])) { inputArray.shift(); fillList(inputArray, overwriteCurrentList); enableRevert(); } else alert("File not valid."); } catch(e) { console.logStringMessage(input + e.toString() ); } } // Imports filters from disc. function importList() { var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker); var stream = Components.classes["@mozilla.org/network/file-input-stream;1"].createInstance(Components.interfaces.nsIFileInputStream); var streamIO = Components.classes["@mozilla.org/scriptableinputstream;1"].createInstance(Components.interfaces.nsIScriptableInputStream); var overwriteCurrentList = false; var input; var inputArray; var validFile = false; fp.init(window, "Select a File", fp.modeOpen); fp.appendFilters(fp.filterText); if (fp.show() != fp.returnCancel) { stream.init(fp.file, 0x01, 0444, null); streamIO.init(stream); input = streamIO.read(stream.available()); streamIO.close(); stream.close(); /* var breakStart = 9, breakEnd = 9-1; // the index just after adblock's header while (/\s/.test(input.charAt(breakEnd+1)) ) breakEnd++; var linebreak = input.substring(breakStart, breakEnd);// substring takes two indices, while substr takes index + length */ // now: unix + mac + dos environment-compatible linebreak = input.match(/(?:\[Ad[Bb]lock\])(((\n+)|(\r+))+)/m)[1]; // first: whole match -- second: backref-1 -- etc.. inputArray = input.split(linebreak); var headerRe = /\[Ad[Bb]lock\]/; // tests if the first line is adblock's header if (headerRe.test(inputArray[0])) { inputArray.shift(); var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService); var msg = "Do you want to Replace your current filters?\n..or Append to them?", title = "Adblock Import", appendLabel = "Append", replaceLabel = "Replace", cancelLabel="Cancel Import"; var flags = promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_2 + promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_1 + promptService.BUTTON_TITLE_IS_STRING * promptService.BUTTON_POS_0 + (promptService.BUTTON_POS_0_DEFAULT?promptService.BUTTON_POS_0_DEFAULT:0); var buttonPressed = promptService.confirmEx(window,title,msg,flags,cancelLabel,replaceLabel,appendLabel,null,{}); if (buttonPressed == 0) return; // second confirm -- user cancelled. var shouldAppend = (buttonPressed == 2); fillList(inputArray, !shouldAppend); enableRevert(); } else alert("File not valid."); } } // Exports the current list of filters to a file on disc. function exportList() { var fp = Components.classes["@mozilla.org/filepicker;1"].createInstance(Components.interfaces.nsIFilePicker); var stream = Components.classes["@mozilla.org/network/file-output-stream;1"].createInstance(Components.interfaces.nsIFileOutputStream); fp.init(window, "Select a File", fp.modeSave); fp.defaultExtension=".txt"; fp.appendFilters(fp.filterText); if (fp.show() != fp.returnCancel) { if (fp.file.exists()) fp.file.remove(true); fp.file.create(fp.file.NORMAL_FILE_TYPE, 0666); stream.init(fp.file, 0x02, 0x200, null); stream.write("[Adblock]" + linebreak.string(), 9 + linebreak.length()); Patterns = getPatterns().split(" "); var appShell = Components.classes["@mozilla.org/appshell/appShellService;1"].getService(Components.interfaces.nsIAppShellService); var hiddenWnd = appShell.hiddenDOMWindow; // global hidden-window var asArray = hiddenWnd.exportWhitelist('asArray'), i=-1, a; if (asArray.length) { while(asArray[++i]) asArray[i] = '##'+asArray[i]; Patterns = asArray.concat(Patterns); } for (var i = 0; i < Patterns.length ; i++) { stream.write(Patterns[i], Patterns[i].length); if (i < (Patterns.length - 1)) stream.write(linebreak.string(), linebreak.length()); } stream.close(); } } var linebreak = { string:function() { var mac= /mac/i.test(navigator.platform); var win= /win/i.test(navigator.platform); var unix= /lin|unix|x11/i.test(navigator.platform); if (win) return "\r\n"; else if (mac) return "\r"; else return "\n"; }, length:function() { var win= /win/i.test(navigator.platform); return (win) ? 2 : 1; } }; // Creates a listitem with the proper children for inline-editing -- returns the item's node -- label is set to 'value' function createListItem(value) { var list = document.getElementById("list"); var newItem = document.createElement("listitem"); value = value.replace(/[\s]*/g, ""); // remove whitespace(s) first -! (for list-import) newItem.setAttribute("label", value); // sets the listItem's label for later saving -- needed by saveSettings() -- deactivateModify does this too. //newItem.setAttribute("context", "listitem-contextmenu"); newItem.setAttribute("ondblclick", "listClickControl();"); list.appendChild(newItem); return newItem; } // This function removes illegal characters (at the moment, space) from the patterns. function makePattern(pat) { var res = ""; for (var i = 0 ; i < pat.length ; i++) { switch (pat[i]) { case ' ' : break; default : res += pat[i]; break; } } return res; } // receives keypresses from the list-area... and makes decisions :) function listKeyControl(eventX) { var keyCodeX = eventX.keyCode; // action-key or '0' var charCodeX = eventX.charCode; // character-key or '0' keyCodeX += charCodeX; // since one of them is always zero, this works var list = document.getElementById("list"); var modifying = findElementWithAttribute("listitem", "modifying", "true"); var listpress = (eventX.target.id == "list" && list.selectedItem); var boundParent = document.getBindingParent(eventX.originalTarget); var entrypress = (boundParent && boundParent.id == "newfilter" && eventX.originalTarget.value != ""); switch (keyCodeX) { // called by 'delete' case eventX.DOM_VK_BACK_SPACE: case eventX.DOM_VK_DELETE: if (!modifying && listpress) removeFilter(); // it's possible the user will click another item, but hit 'return' fast enough to be editing the previous one -- the selection index wasn't updated before the keypress break; // called by 'return' case eventX.DOM_VK_RETURN: case eventX.DOM_VK_ENTER: if (modifying) deactivateModify("return"); // if a filter was being modified else if (listpress) activateModify(); // if a filter was selected + focused else if (entrypress) addFilter(); // if the entry-area was selected + filled else { addFilter(); saveSettings(); } // we're finished break; // called by 'esc' case eventX.DOM_VK_ESCAPE: case eventX.DOM_VK_CANCEL: if (modifying) deactivateModify("esc"); // sends the 'esc' parameter, which signals to keep the old value else saveSettings(); // window.close(); // we're finished break; } } // receives mouseClicks from the list-area... and makes decisions :) function listClickControl() { var list = document.getElementById("list"); var selected = list.selectedItem; var modifying = findElementWithAttribute("listitem", "modifying", "true"); // if we have a filter selected and in-focus if (selected && selected.focus) { // if we're not modifying anything already if (!modifying) { activateModify(); } // we're already modifying something else { // if we want to activate a different item if (modifying != selected) { deactivateModify(); activateModify(); } } } // the listbox lost focus else { if (modifying &! modifying.focused) { deactivateModify(); } } } function finishEdit() { var list = document.getElementById('list'); var modified = findElementWithAttribute("listitem", "modifying", "true"); if (modified && modified != list.selectedItem) { var item = list.selectedItem; deactivateModify(); list.selectedItem = item; } } // activates the textbox for filter modification -- called by modifyFilter function activateModify() { var list = document.getElementById("list"); if (list.selectedItem) { var selectedX = list.selectedItem; var selectedXcell = document.getAnonymousNodes(selectedX)[0]; var selectedXfield = document.getAnonymousNodes(selectedX)[1]; var filter = selectedXcell.getAttribute("label"); var selectedIndex = list.selectedIndex; var scrollView = list.getIndexOfFirstVisibleRow(); var visibleRows = list.getNumberOfVisibleRows(); // if the selected item isn't visible, show it if (selectedIndex < scrollView || selectedIndex > (scrollView + visibleRows-1)) list.scrollToIndex(selectedIndex - (visibleRows/2) + ((visibleRows%2)?1:0)); // set it mid-screen, rounding up /* // if the selected item isn't visible, show it if (list.selectedIndex < list.getIndexOfFirstVisibleRow() || list.selectedIndex > (list.getIndexOfFirstVisibleRow()+list.getNumberOfVisibleRows()-1)) list.scrollToIndex(list.selectedIndex - (list.getNumberOfVisibleRows()/2)); // set it mid-screen */ selectedX.setAttribute("modifying", "true"); selectedXcell.hidden = "true"; selectedXfield.value = filter; selectedXfield.setAttribute("hidden", "false"); selectedX.removeAttribute("ondblclick"); list.blur() selectedXfield.focus(); selectedXfield.setAttribute("onblur", "deactivateModify(event.target);"); } } // deactivates the textbox for filter modification -- called by modifyFilter function deactivateModify(parameter) { var modifying = findElementWithAttribute("listitem", "modifying", "true"); if (modifying) { var list = document.getElementById("list"); var selectedIndex = list.selectedIndex; var selected = list.selectedItem; var disableX = modifying; var disableXcell = document.getAnonymousNodes(disableX)[0]; var disableXfield = document.getAnonymousNodes(disableX)[1]; var disableXindex = list.getIndexOfItem(disableX); var filter = makePattern(disableXfield.value); // note: 'value' needs to be called by method, not property // if the filter isn't blank, *And* we weren't called by the "esc" key if (filter != "" && parameter != "esc") { disableXcell.setAttribute("label", filter); // save the filter disableX.setAttribute("label", filter); // listitem's label: used for later saving -- needed by saveSettings() -- createListItem does this too. enableRevert(); } disableXcell.setAttribute("hidden", "false"); disableXfield.setAttribute("hidden", "true"); disableXfield.removeAttribute("onblur"); disableX.setAttribute("ondblclick", "listClickControl();"); list.selectedIndex = disableXindex; // restore selection list.currentItem = list.getItemAtIndex(list.selectedIndex); // and make it the current item list.focus(); // refocus the list -- doesn't interfere with refocusing on other controls, but does refocus the *Window* if we were called by losing it to another // keep this for last, so listKeyControl wont accidentally activate the wrong field // --(if the user deselects and then presses 'return' fast enough) disableX.setAttribute("modifying", "false"); } } // Removes the selected entry from the list and sets selection to the next item function removeFilter() { var list = document.getElementById("list"); var textbox = document.getElementById("newfilter"); // if we have an item to remove if (list.selectedItem) { var item = list.selectedItem; var itemindex = list.getIndexOfItem(item); // the current item's index var itemplace = itemindex + 1; // this avoids negative numbers later -- 'itemindex' is zero-based var nextitemindex = itemindex; // points to the next item -- equal, since the item below will move up the index once our current item is removed var previtemindex = nextitemindex - 1; // points to the previous -- in case we deleted the lowest entry var originaltotal = list.getRowCount(); // number of items in list, originally var currenttotal = originaltotal-1; // number of items after deletion var itemsfollowing = originaltotal - itemplace; // number of items following the deleted item list.removeChild(item); enableRevert(); // if we have any items left to select if (currenttotal > 0) { //if there's any items following our deleted entry if (itemsfollowing > 0 ) list.selectedIndex = nextitemindex; // sets the list-selection to the next item else list.selectedIndex = previtemindex; // sets the list-selection to the previous item list.ensureIndexIsVisible(list.selectedIndex); // scrolls the list to show the item } } } // Checks all elements of the specified tagname for an attribute match ON THEIR PARENT --returns first match function findElementWithParentAttribute(elementTagName, attributeX, valueX) { var elementarrayX = document.getElementsByTagName(elementTagName); for (var z = 0 ; z < elementarrayX.length ; z++) { var element = elementarrayX[z]; if (element.parentNode) { if (element.parentNode.hasAttribute(attributeX)) { if (element.parentNode.getAttribute(attributeX) == valueX) { return element; } } } } return false; // failure. } // Checks all elements of the specified tagname for an attribute match -- returns first match function findElementWithAttribute(elementTagName, attributeX, valueX) { var elementarrayX = document.getElementsByTagName(elementTagName); for (var z = 0 ; z < elementarrayX.length ; z++) { var element = elementarrayX[z]; if (element.hasAttribute(attributeX) && element.getAttribute(attributeX) == valueX) return element; } return false; // failure. } // sets the flag-parameter [+ timer] for button-menu "hovering" -- called by the menus when they show / hide function setMenuStatus(thisMenu) { var thisButton, activeButton, activeMenu; // flag to inform filter-contextMenu -- workaround for coordinate-bug" //if (!buttonMenusLoaded) buttonMenusLoaded = true; // MOVED: to 'popupshowing' window-listener in settings.xul if (thisMenu) { thisButton = document.getElementsByAttribute("popup", thisMenu.getAttribute("id"))[0]; thisButton.setAttribute("AdblockMenuActivated", true); //menuTimer = setInterval('clearInterval(menuTimer); document.getElementById(document.getElementsByAttribute("AdblockMenuActivated", "true")[0].getAttribute("popup")).hidePopup(); setMenuStatus(null);',10000); } else { activeButton = document.getElementsByAttribute("AdblockMenuActivated", "true"); activeButton = (activeButton.length) ? activeButton[0]:null; // get the first one, if anything returns if (activeButton) activeButton.removeAttribute("AdblockMenuActivated"); if (menuTimer) clearInterval(menuTimer); } } // handles the button-menu's, when they're active // -- for "menu-less" buttons, 'thisButton' is passed as null function checkButtonMenu(thisButton, noMenu) { var currentButton, currentMenu, currentMenuId, thisMenu, thisMenuId; var eventN; currentButton = document.getElementsByAttribute("AdblockMenuActivated", "true"); currentButton = (currentButton.length) ? currentButton[0]:null; // get the first one, if anything returns // if menu's are active if (currentButton) { // if we're hovering over a "nothing" menu-button.. if (noMenu) { // ..and the *ACTIVE* menu is not a "nothing" menu if (!currentButton.hasAttribute("NothingMenu")) { currentMenuId = currentButton.getAttribute("popup"); // get the id of the active menu currentMenu = document.getElementById(currentMenuId); // get the active menu currentMenu.hidePopup(); // hide the first menu currentMenu.removeAttribute("AdblockActivated"); // remove the "menu-active" flag if (menuTimer) clearInterval(menuTimer); // clear the menu-timer } thisButton.setAttribute("AdblockMenuActivated", true); // set the "menu-active" flag thisButton.setAttribute("NothingMenu", "true"); // we're hovering over a "nothing" menu ;P menuTimer = setInterval('clearInterval(menuTimer); setMenuStatus(null);',10000); // set the menu-timer } // we're hovering over a "regular" menu-button else { currentMenuId = currentButton.getAttribute("popup"); // get the id of the active menu currentMenu = document.getElementById(currentMenuId); // get the active menu thisMenuId = thisButton.getAttribute("popup"); // get the hovered button's menu // if the active menu doesn't match to the button we're hovering over if (currentMenuId != thisMenuId) { if (! currentButton.hasAttribute("NothingMenu")) currentMenu.hidePopup(); // close the active menu setMenuStatus(null); // remove all menu-flags // fire the button-click to activate our new menu eventN = document.createEvent("MouseEvents"); eventN.initMouseEvent("mousedown", true, false, null, 0, 0, 0, 0, 0, false, false, false, false, 0, null); thisButton.dispatchEvent(eventN); // fire a mouse-event to activate the second menu } } } } // deactivates the menu-hovering of "nothing" menus when a specified window-event is fired // -- currently for 'keypress' and 'click' function checkMenuEvent() { var activeButton = document.getElementsByAttribute("AdblockMenuActivated", "true"); activeButton = (activeButton.length) ? activeButton[0]:null; // get the first one, if anything returns //var activeMenuId; //var activeMenu; if (activeButton && activeButton.hasAttribute("NothingMenu")) { //activeMenuId = activeButton.getAttribute("popup"); // get the id of the active menu //activeMenu = document.getElementById(activeMenuId); // get the active menu //activeMenu.hidePopup(); setMenuStatus(null); // remove all menu-flags } } // selects a listitem and pops its context-menu function activateContext(evt) { var targetItem = evt.target; if(!targetItem || targetItem.nodeName != "listitem") return; // the user clicked on empty-space or the scrollbar var list = document.getElementById("list"); var listContextMenu = document.getElementById("listitem-contextmenu"); list.selectItem(targetItem); if (!buttonMenusLoaded) var x = evt.screenX, y = evt.screenY; // if the_button-menus/any_contextMenus have been activated, use local-coordinates.. else x = evt.clientX, y = evt.clientY; // ..otherwise, use global-coordinates. listContextMenu.showPopup(targetItem, x, y, "context", "at_pointer","at_pointer"); //if (!buttonMenusLoaded) buttonMenusLoaded = true; // the first context-click doesn't fire its 'popupshowing' event in the proper window } // sets the list-sort pref from its menuitem // -- this is separate from "saveSettings", so we can disable it if we somehow have it set, but don't want the list to be saved as sorted function setListSort(menuItem) { var listOptionsMenu = document.getElementById("options-menu"); listOptionsMenu.hidePopup(); var listSortChecked = menuItem.getAttribute("checked"); if (!listSortChecked) listSortChecked = false; else listSortChecked = true; // for some reason, this attribute passes a string instead of a boolean -! try { var prefObj = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); var Branch = prefObj.getBranch("adblock."); Branch.setBoolPref("listsort", listSortChecked); if (listSortChecked == true && sortFlag == 0) alert("OK. The list will be sorted next time you launch the prefs."); sortFlag++; } catch(e) {} } // reselects the currentItem, since the list deselects it on scroll // -- this could just be my old build of mozilla, trippin'... // -- "dang" - the hbox also calls at each keypress when an inline-edit is active: now checks 'modifying' function reSelectListItem() { var list = document.getElementById("list"); var modifying = findElementWithAttribute("listitem", "modifying", "true"); // if we're not modifying anything if (!modifying) { list.selectedIndex = list.getIndexOfItem(list.currentItem); // reselect our current item list.currentItem = list.currentItem; } } // persists the list's scroll-view by saving a "backup" copy // --because the normal "persist-attribute" route isn't working for this one function persistListIndex() { var list = document.getElementById("list"); var visibleRows = list.getNumberOfVisibleRows(); var scrollView = list.getIndexOfFirstVisibleRow(); var selectedIndex = list.selectedIndex; /* DISABLED: it feels more natural not to use this if (scrollView > selectedIndex) scrollView = selectedIndex; // if the selected-item is hidden above, set the view to it else if (selectedIndex > (scrollView + visibleRows - 1)) scrollView = selectedIndex - visibleRows + 1; // if the selected-item is hidden below, set the view to show it last */ list.setAttribute("persist-scrollView", scrollView); list.setAttribute("persist-selectedIndex", selectedIndex); } // restores the list's selected-index from the persisted "backup" function restoreListIndex(filterURL) { var list = document.getElementById("list"); var textbox = document.getElementById("newfilter"); var savedView, savedIndex; if (!filterURL) filterURL = window._filterURL; // if the list is empty if (list.getRowCount() == 0) return textbox.focus(); // throw focus to the input-line if (filterURL && listKeys[filterURL]) savedView = savedIndex = list.getIndexOfItem(listKeys[filterURL]); else { savedView = list.getAttribute("persist-scrollView"); savedIndex = list.getAttribute("persist-selectedIndex"); } // otherwise, restore the scroll-view and select the last-saved index //else { // if we have a valid scroll-view and index if ((savedView && savedView != -1 && savedView <= list.getRowCount()-1) && (savedIndex && savedIndex != -1 && savedIndex <= list.getRowCount()-1)) { list.focus(); //list.scrollToIndex(list.getRowCount()-1); // scroll to the last item -- so our next scroll lends the "complete" view list.scrollToIndex(savedView); // scroll the list to show the index -- more impressive :) //list.ensureIndexIsVisible(savedView); // jump to the given index -- the 'fallback' in case scrollto.. fails list.selectedIndex = savedIndex; // select the current item list.currentItem = list.selectedItem = list.getItemAtIndex(savedIndex); //list.ensureIndexIsVisible(savedIndex); // make sure we can see the current item //list.selectedIndex = savedIndex; // re-select the current item (in case it wasn't visible) if (filterURL) setTimeout(function(){activateModify();},300); } else { list.focus(); list.ensureIndexIsVisible(list.getRowCount() - 1); // scroll to the last item -- -1 to make zero-based list.selectedIndex = list.getRowCount() - 1; // select the item we just scrolled to } //} } // Returns the patterns in one, long string. // Use split(" ") to turn it into an array. function getPatterns() { var patterns = new Array(); var list = document.getElementById("list"); for (var i = 0 ; i < list.childNodes.length ; i++) if (! /^\s$/.test(list.childNodes[i].getAttribute("label")) ) patterns.push(list.childNodes[i].getAttribute("label")); // if the pattern isn't just whitespace, add it in patterns = patterns.join(" "); return patterns; } // enables the Revert-button once a setting has changed function enableRevert() { var revertButton = document.getElementById("revertbutton"); if (revertButton.disabled) revertButton.setAttribute("disabled", false); } // confirms and executes a settings-revert to the last saved state function revertSettings() { var confirmRevert = confirm("Are you sure you want to revert?\n..all changes for this pref-session will be undone." ); if (confirmRevert) { loadPrefWindow(); var revertButton = document.getElementById("revertbutton") revertButton.setAttribute("disabled", true); } } // Save the settings and close the window. function saveSettings() { var revertButton = document.getElementById("revertbutton"); var somethingChanged = (revertButton.getAttribute("disabled") == "false"); // if the revert-button isn't disabled, something was changed var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService); var prefObj = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService); var Branch = prefObj.getBranch("adblock."); // only save if we've actually changed something if (somethingChanged) { var patterns = getPatterns(); Branch.setCharPref("patterns", patterns); observerService.notifyObservers(null, "Adblock-PrefChange", "FilterChange"); var enablebox = document.getElementById("enabled"); Branch.setBoolPref("enabled", enablebox.checked); var frameobjects = document.getElementById("frameobjects"); Branch.setBoolPref("frameobjects", (frameobjects.getAttribute("checked") == "true") ? true:false); var slowcollapse = document.getElementById("slowcollapse"); Branch.setBoolPref("fastcollapse", (slowcollapse.getAttribute("checked") == "true") ? false:true); // reverse-pref: slow -> fast var linkcheck = document.getElementById("linkcheck"); Branch.setBoolPref("linkcheck", (linkcheck.getAttribute("checked") == "true") ? true:false); var pageblock = document.getElementById("pageblock"); Branch.setBoolPref("pageblock", (pageblock.getAttribute("checked") == "true") ? true:false); var radiohide = document.getElementById("radio-hide"); Branch.setBoolPref("hide", radiohide.selected); //var collapsebox = document.getElementById("fastcollapse"); //Branch.setBoolPref("fastcollapse", collapsebox.checked); //prefObj.savePrefFile(null); // save the prefs to disk -- component.js "loadSettings()" handles this now observerService.notifyObservers(null, "Adblock-SavePrefFile", null); } persistListIndex(); // persists the current listitem's index in a separate listbox-attribute window.close(); // close out. -- triggers an 'onclose' handler to call "loadSettings()" *in the overlay* } // loads a help page -- needs to be passed a case-variable 'whichPage' function loadHelpPage(whichPage) { var pageUrl; switch(whichPage) { case "about": pageUrl = "http://adblock.mozdev.org/"; break; case "regexp": pageUrl = "http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:RegExp"; break; } var windowService = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator); var currentWindow = windowService.getMostRecentWindow("navigator:browser"); if (currentWindow) { try { currentWindow.delayedOpenTab(pageUrl); } catch(e) { currentWindow.loadURI(pageUrl); } } else window.open(pageUrl); } PK /42ffycontent/settings.xmlSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT YDDD 0 0 false null null null 0 "" 0 ? this.getIndexOfItem(this.selectedItems[0]) : -1; ]]> = 0) this.selectItem(this.getItemAtIndex(val)); else this.clearSelection(); ]]> 0 ? this.selectedItems[0] : null; ]]> 0) return this.selectedItem.value; else return null; ]]> = 0; --i) this.selectedItems[i].selected = false; this.selectedItems.splice(0, this.selectedItems.length); } this._selectionStart = null; this._fireOnSelect(); ]]> return this.listBoxObject.getIndexOfItem(item); return this.listBoxObject.getItemAtIndex(index); return this.listBoxObject.ensureIndexIsVisible(index); return this.ensureIndexIsVisible(this.listBoxObject.getIndexOfItem(element)); return this.listBoxObject.scrollToIndex(index); return this.listBoxObject.getNumberOfVisibleRows(); return this.listBoxObject.getIndexOfFirstVisibleRow(); return this.listBoxObject.getRowCount(); 1 ) this.removeItemFromSelection(this.selectedItems[l-1]); if ( l <= 2 ) this._isDownSelection=0; } else { this.addItemToSelection(n); this._isUpSelection=1; } } ]]> 1 ) this.removeItemFromSelection(this.selectedItems[l-1]); if ( l <= 2 ) this._isUpSelection=0; } else { this.addItemToSelection(n); this._isDownSelection=1; } } ]]> = count - v ) n=this.getItemAtIndex(count - 1); else { n = this.getNextItem(this.selectedItems[l-1], v); var newIndex = i + v; if ( ! n || newIndex > count - v ) { newIndex = count - v; n = this.getItemAtIndex(newIndex + this.getIndexOfItem(this.selectedItems[l-1]) - i); } this.scrollToIndex(newIndex); } this.timedSelect(n, 500); ]]> 0 && !event.altKey && !event.ctrlKey && !event.shiftKey && !event.metaKey) { var key = String.fromCharCode(event.charCode); key = key.toLowerCase(); if (event.timeStamp - this._lastKeyTime > 1000) this._incrementalString = key; else { if (this._incrementalString.length != 1 || this._incrementalString.charAt(0) != key.charAt(0)) this._incrementalString += key; } this._lastKeyTime = event.timeStamp; var l = this.selectedItems.length; var c = -1; if (l > 0) c = this.getIndexOfItem(this.selectedItems[l-1]); var rowCount = this.getRowCount(); var start = 1; if (this._incrementalString.length > 1) { start = 0; if (c < 0) c = 0; } for (var i = 0; i < rowCount; i++) { var k = (i + start + c) % rowCount; var item = this.getItemAtIndex(k); //listitem var cellText = item.getAttribute("label"); cellText = cellText.toLowerCase(); if (cellText.search(this._incrementalString) == 0) { this._isUpSelection=0; this._isDownSelection=0; this.ensureIndexIsVisible(k); this.timedSelect(item, 500); break; } } } ]]> PK zY4wYYycontent/settings.xulSDdۓcd`ia``0bbFV0UH n&9I73n9F&&Vxaa%' @B&`WUT DDD