diff --git a/.gitignore b/.gitignore index 5ebd21a..02d3419 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,4 @@ pip-log.txt # Mac crap .DS_Store +{E6C1199F-E687-42da-8C24-E7770CC3AE66} diff --git a/ReadMe.txt b/ReadMe.txt index 18e43c9..effa0a2 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -1,11 +1,28 @@ +This plugin is Obsolete as of FF 57. + +For additional information please visit: +http://quickjavaplugin.blogspot.com/2017/10/quickjava-to-be-obsolete-with-firefox.html + + +Old Notes: + //QuickJava //By Doug G. // //Allows quick enable and disable of Java, Javascript, Cookies, Image Animations, Flash, Silverlight, Images, Stylesheets and Proxy -//from the Statusbar and/or Toolbar. +//from the Add-on bar and/or Toolbar. +// +//License: https://www.mozilla.org/en-US/MPL/1.1/ // //Version History -//Version 2.0 Major update! Favorite toolbar button added (auto-install needed). Middle click only toggles visible status bar values. Customizable startup options. Update icons after customization +//Version 2.1.0 Add WebGL (thanks ccrtnsp) and WebRTC support. Move preferences to extensions branch. Fix CSS toggle bugs. Fix Options 'Reset' buttons bug. Fix install/new version popup. Add jp locale (thanks to Hideki!) Also thanks to Gitoffthelawn, Compyooter, staudenmeir, and jimbo1qaz for bug reports and communication. +//Version 2.0.8 Add error handling due to CSS method sometimes throwing an exception, have not figured out what causes this yet +//Version 2.0.7 Changed how the stylesheets are being read due to change in FF44 +//Version 2.0.6 Fixed a bug when customizing some toolbars, thanks to Quicksaver (the developer of the Puzzle Toolbar addon) for the code +//Version 2.0.5 Fixed a bug when toggling CSS +//Version 2.0.4 Fixed a bug when using the dropdown of the QJ Favorites to toggle settings +//Version 2.0.3 Fixed a bug causing issues with other addons. +//Version 2.0.2 Major update! Favorite toolbar button added (auto-install for new users or 1.8.0 and below). Middle click only toggles visible status bar values. Customizable startup options. Update icons after customization. //Version 1.8.1.1 ClickToPlay as an option (hidden) for Enabled state //Version 1.8.1 Update to work with FF23 and above, fix button spacing and skinning (provided by anonymous user), Slight change to look of icons to modernize (provided by Dave). //Version 1.8.0 Back to Red buttons, a few minor bug fixes and added links on Options page. Thanks again to Dave for more help. diff --git a/chrome.manifest b/chrome.manifest index 49d211b..7a0f053 100644 --- a/chrome.manifest +++ b/chrome.manifest @@ -6,4 +6,5 @@ skin quickjava classic/1.0 chrome://quickjava/content/skin/classic/quickjava/ style chrome://browser/content/browser.xul chrome://quickjava/skin/quickjava.css style chrome://global/content/customizeToolbar.xul chrome://quickjava/skin/quickjava.css locale quickjava en-US locale/en-US/ -locale quickjava es locale/es/ \ No newline at end of file +locale quickjava es locale/es/ +locale quickjava jp locale/jp/ diff --git a/content/browserOverlay.js b/content/browserOverlay.js index a901a46..91b5a26 100644 --- a/content/browserOverlay.js +++ b/content/browserOverlay.js @@ -7,20 +7,22 @@ if(!thatoneguydotnet.QuickJava) thatoneguydotnet.QuickJava={}; thatoneguydotnet.QuickJava={ -onLoad: function(evt) - { - this.errMsg = ''; - this.debugMode = true; - this.alertPluginNames = false; - this.alertPluginNamesOnMatch = false; - this.curVersion = ''; - this.firstInstallUrl = ''; - this.newVersionUrl = ''; - this.massToggle = false; - - try - { - this.qj_Prefix_Pref = 'thatoneguydotnet.QuickJava'; +qj_JS : 'JavaScript', +qj_J : 'Java', +qj_F : 'Flash', +qj_WebGL : 'WebGL', +qj_WebRTC : 'WebRTC', +qj_SL : 'Silverlight', +qj_AI : 'AnimatedImage', +qj_C : 'Cookies', +qj_I : 'Images', +qj_CS : 'CSS', +qj_P : 'Proxy', + +initQJ: function() + { + this.qj_Prefix_Pref = 'extensions.thatoneguydotnet.QuickJava'; + this.qj_Prefix_PrefOld = 'thatoneguydotnet.QuickJava'; this.Plugin_TopicStr = this.qj_Prefix_Pref + ".plugins.refreshIcons"; this.qj_Pref_CustomStyle = '.custombuttonstyle'; this.qj_Pref_Default = '.default'; @@ -39,24 +41,28 @@ onLoad: function(evt) this.qj_Prefix_Sb_Container = this.qj_Prefix_Sb + 'Container_'; this.qj_Prefix_Tb = this.qj_Prefix + 'ToolbarIcon_'; this.qj_Prefix_Tb_Container = this.qj_Prefix_Tb + 'Container_'; - - this.qj_JS = 'JavaScript'; - this.qj_J = 'Java'; - this.qj_F = 'Flash'; - this.qj_SL = 'Silverlight'; - this.qj_AI = 'AnimatedImage'; - this.qj_C = 'Cookies'; - this.qj_I = 'Images'; - this.qj_CS = 'CSS'; - this.qj_P = 'Proxy'; + this.qj_Prefix_Tb_FM_Container = this.qj_Prefix_Tb_Container + 'Favorites_Menu_'; this.qj_Fav = 'Favorites'; this.qj_Fav_Different = this.qj_Fav + '_Different'; + }, + +onLoad: function(evt) + { + if (typeof(Ci) == 'undefined') { return false; } //This is not a normal window (example: options dialog) + this.alertPluginNames = false; + this.alertPluginNamesOnMatch = false; + this.firstInstallUrl = 'http://quickjavaplugin.blogspot.com/p/welcome.html'; + this.newVersionUrl = 'http://quickjavaplugin.blogspot.com/2016/08/new-version-210.html'; + + this.curVersion = ''; //do not initialize, automatically loaded + this.massToggle = false; //program use, do not initialize to true + try + { this.customStyleIndxDefault = -1; this.customStyleIndxEnabled = -1; - if (!Ci) { return false; } //This is not a normal window (example: options dialog) this.Plugin = Components.classes["@mozilla.org/observer-service;1"] .getService (Components.interfaces.nsIObserverService); this.prefs = Components.classes["@mozilla.org/preferences-service;1"]. @@ -64,6 +70,7 @@ onLoad: function(evt) //Initialize pref monitors this.onLoadDetails(); + this.movePreferences(); //First startup routine if (Components.classes["@mozilla.org/appshell/window-mediator;1"] @@ -71,11 +78,11 @@ onLoad: function(evt) .getEnumerator("").getNext() == window) { this.firstStartup(); - this.setStartupValues(0); + setTimeout('thatoneguydotnet.QuickJava.setStartupValues(0);',10); } else { - this.setStartupValues(1); + setTimeout('thatoneguydotnet.QuickJava.setStartupValues(1);',10); } //Update custom style @@ -83,53 +90,93 @@ onLoad: function(evt) //Update all icons this.updateIcons(); - } catch (e) { this.handleError(e); } - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } + } catch (e) { try { this.handleError(e); } catch (e) {} } }, handleError: function(e) { - this.errMsg = "An exception occurred in the QuickJava script. Error name: " + e.name - + ".\n\n Error description: " + e.description - + ".\n\n Error number: " + e.number - + ".\n\n Error message: " + e.message; + this.consoleLog("An exception occurred in the QuickJava script. Error name: " + e.name + + ".\n Error description: " + e.description + + ".\n Error number: " + e.number + + ".\n Error message: " + e.message + + ".\n Stack: " + e.stack + , true); }, firstStartup: function(e) { - this.curVersion = this.prefs.getCharPref("thatoneguydotnet.QuickJava.curVersion"); + this.curVersion = this.prefs.getCharPref(this.qj_Prefix_Pref + ".curVersion"); Components.utils.import("resource://gre/modules/AddonManager.jsm"); AddonManager.getAddonByID("{E6C1199F-E687-42da-8C24-E7770CC3AE66}", function(addon) { thatoneguydotnet.QuickJava.versionCheck(addon);}); }, versionCheck: function(addon) { - if (this.curVersion != addon.version) + //strip out any non-numeric or decimal characters (such as "signed" text) + var curVersionClean = this.curVersion.replace(/[^\d.]/g, ''); + var addonVersionClean = addon.version.replace(/[^\d.]/g, ''); + if (curVersionClean != addonVersionClean) { - if (this.curVersion == '' && this.firstInstallUrl != '') + if (curVersionClean == '') { - this.openTab(this.firstInstallUrl,true); + this.installButton("nav-bar", "QuickJava_ToolbarIcon_Container_Favorites_Item"); + this.updateIcons(); + if (this.firstInstallUrl != '') + { + setTimeout('thatoneguydotnet.QuickJava.openTab(thatoneguydotnet.QuickJava.firstInstallUrl,true);', 1000); + } } else if (this.newVersionUrl != '') { - this.openTab(this.newVersionUrl,true); + setTimeout('thatoneguydotnet.QuickJava.openTab(thatoneguydotnet.QuickJava.newVersionUrl,true);', 1000); } - this.curVersion = addon.version; - this.prefs.setCharPref("thatoneguydotnet.QuickJava.curVersion", this.curVersion) + curVersionClean = addonVersionClean; + this.prefs.setCharPref(this.qj_Prefix_Pref + ".curVersion", curVersionClean) + } + }, + +installButton: function(toolbarId, id, afterId) + { + if (!document.getElementById(id)) { + var toolbar = document.getElementById(toolbarId); + + // If no afterId is given, then append the item to the toolbar + var before = null; + if (afterId) { + let elem = document.getElementById(afterId); + if (elem && elem.parentNode == toolbar) + before = elem.nextElementSibling; + } + + toolbar.insertItem(id, before); + toolbar.setAttribute("currentset", toolbar.currentSet); + document.persist(toolbar.id, "currentset"); + + if (toolbarId == "addon-bar") + toolbar.collapsed = false; } }, + newTabOpened: function(e) { thatoneguydotnet.QuickJava.setStartupValues(2); }, + +newTabSelected: function(e) +{ + thatoneguydotnet.QuickJava.updateIcons(); +}, + setStartupValues: function(startupType) { /* 0 = initial luanch, 1 = new window, 2 = new tab */ - var runAt = this.prefs.getIntPref('thatoneguydotnet.QuickJava.startupStatus.type'); + var runAt = this.prefs.getIntPref(this.qj_Prefix_Pref + '.startupStatus.type'); if (runAt >= startupType) { this.setStartupValue(this.qj_I); this.setStartupValue(this.qj_J); this.setStartupValue(this.qj_JS); this.setStartupValue(this.qj_F); + this.setStartupValue(this.qj_WebGL); + this.setStartupValue(this.qj_WebRTC); this.setStartupValue(this.qj_SL); this.setStartupValue(this.qj_AI); this.setStartupValue(this.qj_C); @@ -138,16 +185,19 @@ setStartupValues: function(startupType) }, setStartupValue: function(whichIcon) { - /* 0 = no change, 1 = enabled, 2 = disabled */ - var statusToSet = this.prefs.getIntPref('thatoneguydotnet.QuickJava.startupStatus.' + whichIcon); - if (statusToSet > 0) + try { - var turnOn = (statusToSet == 1 ? 1 : 0); - if (this.isEnabled(whichIcon) != turnOn) + /* 0 = no change, 1 = enabled, 2 = disabled */ + var statusToSet = this.prefs.getIntPref(this.qj_Prefix_Pref + '.startupStatus.' + whichIcon); + if (statusToSet > 0) { - this.toggleEnabled(whichIcon); + var turnOn = (statusToSet == 1 ? 1 : 0); + if (this.isEnabled(whichIcon) != turnOn) + { + this.toggleEnabled(whichIcon); + } } - } + } catch (e) { try { this.handleError(e); } catch (e) {} } }, findElement: function(node, childId) { @@ -162,10 +212,10 @@ findElement: function(node, childId) }, getProxyOnValue: function() { - var onValue = this.prefs.getIntPref("thatoneguydotnet.QuickJava.priorvalue.Proxy"); + var onValue = this.prefs.getIntPref(this.qj_Prefix_Pref + ".priorvalue.Proxy"); var curValue = this.prefs.getIntPref("network.proxy.type"); var updateStoredValue = false; - + //If not off, set the new default on value to current value if (curValue != 0 && curValue != onValue) { @@ -180,14 +230,14 @@ getProxyOnValue: function() } if(updateStoredValue) { - this.prefs.setIntPref("thatoneguydotnet.QuickJava.priorvalue.Proxy", onValue); + this.prefs.setIntPref(this.qj_Prefix_Pref + ".priorvalue.Proxy", onValue); } return onValue; }, getCookieOnValue: function() { - var onValue = this.prefs.getIntPref("thatoneguydotnet.QuickJava.priorvalue.Cookie"); + var onValue = this.prefs.getIntPref(this.qj_Prefix_Pref + ".priorvalue.Cookie"); var curValue = this.prefs.getIntPref("network.cookie.cookieBehavior"); var updateStoredValue = false; @@ -205,14 +255,13 @@ getCookieOnValue: function() } if (updateStoredValue) { - this.prefs.setIntPref("thatoneguydotnet.QuickJava.priorvalue.Cookie", onValue); + this.prefs.setIntPref(this.qj_Prefix_Pref + ".priorvalue.Cookie", onValue); } return onValue; }, onClick: function(event) { - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } try { // event.button == 2 // right @@ -224,6 +273,8 @@ onClick: function(event) this.toggleEnabledIfStatusbarVisible(this.qj_J); this.toggleEnabledIfStatusbarVisible(this.qj_JS); this.toggleEnabledIfStatusbarVisible(this.qj_F); + this.toggleEnabledIfStatusbarVisible(this.qj_WebGL); + this.toggleEnabledIfStatusbarVisible(this.qj_WebRTC); this.toggleEnabledIfStatusbarVisible(this.qj_SL); this.toggleEnabledIfStatusbarVisible(this.qj_AI); this.toggleEnabledIfStatusbarVisible(this.qj_C); @@ -232,14 +283,12 @@ onClick: function(event) if (event.button != 0 && event.button != 1) { this.updateIcons(); } - } catch(e) { this.handleError(e); } - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } + } catch (e) { try { this.handleError(e); } catch (e) {} } return true; }, onCommand: function(event) { - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } try { // event.button == 2 // right, not supported onCommand @@ -250,15 +299,13 @@ onCommand: function(event) { this.updateIcons(); } - } catch(e) { this.handleError(e); } - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } + } catch (e) { try { this.handleError(e); } catch (e) {} } return true; }, onCommandFavorites: function(event) { - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } try { // event.button == 2 // right, not supported onCommand @@ -273,6 +320,8 @@ onCommandFavorites: function(event) doReload = (this.toggleEnabledIfFavorite(this.qj_J, turnOn) && this.checkForReload(this.qj_J)) || doReload; doReload = (this.toggleEnabledIfFavorite(this.qj_JS, turnOn) && this.checkForReload(this.qj_JS)) || doReload; doReload = (this.toggleEnabledIfFavorite(this.qj_F, turnOn) && this.checkForReload(this.qj_F)) || doReload; + doReload = (this.toggleEnabledIfFavorite(this.qj_WebGL, turnOn) && this.checkForReload(this.qj_WebGL)) || doReload; + doReload = (this.toggleEnabledIfFavorite(this.qj_WebRTC, turnOn) && this.checkForReload(this.qj_WebRTC)) || doReload; doReload = (this.toggleEnabledIfFavorite(this.qj_SL, turnOn) && this.checkForReload(this.qj_SL)) || doReload; doReload = (this.toggleEnabledIfFavorite(this.qj_AI, turnOn) && this.checkForReload(this.qj_AI)) || doReload; doReload = (this.toggleEnabledIfFavorite(this.qj_C, turnOn) && this.checkForReload(this.qj_C)) || doReload; @@ -285,14 +334,12 @@ onCommandFavorites: function(event) { BrowserReload(); } - } catch(e) { this.handleError(e); } - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } + } catch (e) { try { this.handleError(e); } catch (e) {} } return true; }, reset_pref_click: function(event, whichReset) { - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } try { var optionField = document.getElementById(this.qj_Option_Pref_RegEx + whichReset); @@ -300,32 +347,44 @@ reset_pref_click: function(event, whichReset) { optionField.value = optionField.defaultValue; } - } catch(e) { this.handleError(e); } - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } + } catch (e) { try { this.handleError(e); } catch (e) {} } return true; }, - + GetTypeFromId: function(id) { - if (id == this.qj_Prefix_Sb_Container + this.qj_JS || id == this.qj_Prefix_Tb_Container + this.qj_JS) { return this.qj_JS; } - if (id == this.qj_Prefix_Sb_Container + this.qj_J || id == this.qj_Prefix_Tb_Container + this.qj_J) { return this.qj_J; } - if (id == this.qj_Prefix_Sb_Container + this.qj_F || id == this.qj_Prefix_Tb_Container + this.qj_F) { return this.qj_F; } - if (id == this.qj_Prefix_Sb_Container + this.qj_SL || id == this.qj_Prefix_Tb_Container + this.qj_SL) { return this.qj_SL; } - if (id == this.qj_Prefix_Sb_Container + this.qj_AI || id == this.qj_Prefix_Tb_Container + this.qj_AI) { return this.qj_AI; } - if (id == this.qj_Prefix_Sb_Container + this.qj_C || id == this.qj_Prefix_Tb_Container + this.qj_C) { return this.qj_C; } - if (id == this.qj_Prefix_Sb_Container + this.qj_I || id == this.qj_Prefix_Tb_Container + this.qj_I) { return this.qj_I; } - if (id == this.qj_Prefix_Sb_Container + this.qj_CS || id == this.qj_Prefix_Tb_Container + this.qj_CS) { return this.qj_CS; } - if (id == this.qj_Prefix_Sb_Container + this.qj_P || id == this.qj_Prefix_Tb_Container + this.qj_P) { return this.qj_P; } + if (id == this.qj_Prefix_Sb_Container + this.qj_JS || id == this.qj_Prefix_Tb_Container + this.qj_JS || id == this.qj_Prefix_Tb_FM_Container + this.qj_JS) { return this.qj_JS; } + if (id == this.qj_Prefix_Sb_Container + this.qj_J || id == this.qj_Prefix_Tb_Container + this.qj_J || id == this.qj_Prefix_Tb_FM_Container + this.qj_J) { return this.qj_J; } + if (id == this.qj_Prefix_Sb_Container + this.qj_F || id == this.qj_Prefix_Tb_Container + this.qj_F || id == this.qj_Prefix_Tb_FM_Container + this.qj_F) { return this.qj_F; } + if (id == this.qj_Prefix_Sb_Container + this.qj_WebGL || id == this.qj_Prefix_Tb_Container + this.qj_WebGL || id == this.qj_Prefix_Tb_FM_Container + this.qj_WebGL) { return this.qj_WebGL; } + if (id == this.qj_Prefix_Sb_Container + this.qj_WebRTC || id == this.qj_Prefix_Tb_Container + this.qj_WebRTC || id == this.qj_Prefix_Tb_FM_Container + this.qj_WebRTC) { return this.qj_WebRTC; } + if (id == this.qj_Prefix_Sb_Container + this.qj_SL || id == this.qj_Prefix_Tb_Container + this.qj_SL || id == this.qj_Prefix_Tb_FM_Container + this.qj_SL) { return this.qj_SL; } + if (id == this.qj_Prefix_Sb_Container + this.qj_AI || id == this.qj_Prefix_Tb_Container + this.qj_AI || id == this.qj_Prefix_Tb_FM_Container + this.qj_AI) { return this.qj_AI; } + if (id == this.qj_Prefix_Sb_Container + this.qj_C || id == this.qj_Prefix_Tb_Container + this.qj_C || id == this.qj_Prefix_Tb_FM_Container + this.qj_C) { return this.qj_C; } + if (id == this.qj_Prefix_Sb_Container + this.qj_I || id == this.qj_Prefix_Tb_Container + this.qj_I || id == this.qj_Prefix_Tb_FM_Container + this.qj_I) { return this.qj_I; } + if (id == this.qj_Prefix_Sb_Container + this.qj_CS || id == this.qj_Prefix_Tb_Container + this.qj_CS || id == this.qj_Prefix_Tb_FM_Container + this.qj_CS) { return this.qj_CS; } + if (id == this.qj_Prefix_Sb_Container + this.qj_P || id == this.qj_Prefix_Tb_Container + this.qj_P || id == this.qj_Prefix_Tb_FM_Container + this.qj_P) { return this.qj_P; } }, - + updateIcons: function() { + //this.consoleLog('updateIcons'); + //do as setTimeout so any other processes can finish first + setTimeout('thatoneguydotnet.QuickJava.updateIconsNow();',100); + this.updateIconsNow(); + }, + +updateIconsNow: function() + { + //this.consoleLog('updateIconsNow'); if(!this.massToggle) { //Set the icons this.setIcon(this.qj_JS, this.isEnabled(this.qj_JS)); this.setIcon(this.qj_J, this.isEnabled(this.qj_J)); this.setIcon(this.qj_F, this.isEnabled(this.qj_F)); + this.setIcon(this.qj_WebGL, this.isEnabled(this.qj_WebGL)); + this.setIcon(this.qj_WebRTC, this.isEnabled(this.qj_WebRTC)); this.setIcon(this.qj_SL, this.isEnabled(this.qj_SL)); this.setIcon(this.qj_AI, this.isEnabled(this.qj_AI)); this.setIcon(this.qj_C, this.isEnabled(this.qj_C)); @@ -343,18 +402,20 @@ GetRegEx: function(whichIcon) switch (whichIcon) { case this.qj_J: - return new RegExp(this.prefs.getCharPref("thatoneguydotnet.QuickJava.regex.Java"), 'i'); + return new RegExp(this.prefs.getCharPref(this.qj_Prefix_Pref + ".regex.Java"), 'i'); break; case this.qj_F: - return new RegExp(this.prefs.getCharPref("thatoneguydotnet.QuickJava.regex.Flash"), 'i'); + return new RegExp(this.prefs.getCharPref(this.qj_Prefix_Pref + ".regex.Flash"), 'i'); break; case this.qj_SL: - return new RegExp(this.prefs.getCharPref("thatoneguydotnet.QuickJava.regex.Silverlight"), 'i'); + return new RegExp(this.prefs.getCharPref(this.qj_Prefix_Pref + ".regex.Silverlight"), 'i'); break; } }, setIcon: function(whichIcon, onOff) + { + try { var isHidden = this.prefs.getBoolPref(this.qj_Prefix_Pref_Hide + whichIcon); var statusNumber = (onOff == 1 ? "1" : (onOff == 0 ? "0" : "-2")); @@ -372,6 +433,7 @@ setIcon: function(whichIcon, onOff) favDropDown.setAttribute("checked", onOff == 1 ? true : false); favDropDown.setAttribute("style", this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + whichIcon) ? "" : "display: none;"); } + } catch (e) { try { this.handleError(e); } catch (e) {} } }, setFavIcon: function() @@ -388,7 +450,7 @@ setFavIcon: function() if (differentIndicator) { differentIndicator.setAttribute("status", (anyEnabled && !allEnabled ? "1" : "0")); } }, - // + // GetPluginTags: function() { if (!("nsIPluginHost" in Components.interfaces)) return false; var phs = Components.classes["@mozilla.org/plugin/host;1"] @@ -421,7 +483,8 @@ toggleEnabledIfFavorite: function(whichIcon, turnOn) // Sets plugin enabled status of plugin(s), whose name matches on aRegEx, // to aValue. aName is used for the "not found" message and is optional toggleEnabled: function(whichIcon) { - if (!Ci) { return false; } //This is not a normal window (example: options dialog) + if (typeof(Ci) == 'undefined') { return false; } //This is not a normal window (example: options dialog) + var setEnabled = !this.isEnabled(whichIcon); if (whichIcon == this.qj_JS) { @@ -449,10 +512,18 @@ toggleEnabled: function(whichIcon) { var onValue = this.getProxyOnValue(); this.prefs.setIntPref("network.proxy.type", (setEnabled ? onValue : "0")); } + else if (whichIcon == this.qj_WebGL) + { + this.prefs.setBoolPref("webgl.disabled", !setEnabled); + } + else if (whichIcon == this.qj_WebRTC) + { + this.prefs.setBoolPref("media.peerconnection.enabled", setEnabled); + } else { var aRegEx = this.GetRegEx(whichIcon); - if (!aRegEx) { if (this.debugMode) { alert('Invalid toggleEnabled: ' + whichIcon); } return; } + if (!aRegEx) { this.consoleLog('Invalid toggleEnabled: ' + whichIcon); return; } var plugins = this.GetPluginTags(); if (!plugins) return; var found = false; @@ -464,7 +535,7 @@ toggleEnabled: function(whichIcon) { { plugins[i].enabledState = (setEnabled ? Ci.nsIPluginTag.STATE_ENABLED : Ci.nsIPluginTag.STATE_DISABLED); //Doesn't seem to be working, Flash still runs on the test page w/o asking after setting to CLICKTOPLAY - if (setEnabled && this.prefs.getBoolPref("thatoneguydotnet.QuickJava.enabledState.ClickToPlay")) { + if (setEnabled && this.prefs.getBoolPref(this.qj_Prefix_Pref + ".enabledState.ClickToPlay")) { plugins[i].enabledState = Ci.nsIPluginTag.STATE_CLICKTOPLAY; //alert(plugins[i].enabledState + ', ' + Ci.nsIPluginTag.STATE_CLICKTOPLAY); } @@ -482,9 +553,10 @@ toggleEnabled: function(whichIcon) { var wm = Components.classes['@mozilla.org/appshell/window-mediator;1'] .getService(Components.interfaces.nsIWindowMediator); var window = wm.getMostRecentWindow(null); - msgAlert(window, "No " + aName + " plugin found!"); + this.consoleLog(window, "No " + aName + " plugin found!"); } } + this.updateIcons(); if(!this.massToggle && this.checkForReload(whichIcon)) { @@ -495,6 +567,8 @@ checkForReload: function(whichIcon) { return this.prefs.getBoolPref(this.qj_Prefix_Pref_Reload + whichIcon); }, + + setStyleDisabledExtended: function(turnOff) { if (turnOff) @@ -512,7 +586,18 @@ setStyleDisabledExtended: function(turnOff) { if ("gPageStyleMenu" in window) { - gPageStyleMenu.switchStyleSheet(''); + var setSheet = ''; + var firstSheet = ''; + var curSheetAry = gPageStyleMenu.getBrowserStyleSheets(); + for (curSheetIdx in curSheetAry) { + //this.consoleLog('gPageStyleMenu *' + curSheetAry[curSheetIdx].title + '*'); + setSheet = curSheetAry[curSheetIdx].title; + if (curSheetAry[curSheetIdx].title == 'screen') { break; } + if (firstSheet == '') { firstSheet = setSheet; } + } + //if we didn't find one named 'screen' then use the first one we found + if (setSheet != 'screen') { setScreen = firstSheet; } + gPageStyleMenu.switchStyleSheet(setSheet); } else { @@ -539,46 +624,48 @@ openTab: function(url, focusTab) { openHelp: function() { - try - { + try { this.openTab('http://quickjavaplugin.blogspot.com/2012/07/quickjava-quick-help.html',true); - } catch (e) { this.handleError(e); } - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } + } catch (e) { try { this.handleError(e); } catch (e) {} } }, openHome: function() { - try - { + try { this.openTab('http://quickjavaplugin.blogspot.com/',true); - } catch (e) { this.handleError(e); } - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } + } catch (e) { try { this.handleError(e); } catch (e) {} } }, -openDonate: function() -{ - try - { +openDonate: function() { + try { this.openTab('https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9DSQG8KAB95C6',true); - } catch (e) { this.handleError(e); } - if (this.debugMode && this.errMsg != '') { alert(this.errMsg); this.errMsg = ''; } + } catch (e) { try { this.handleError(e); } catch (e) {} } }, -showOptions: function() - { - window.openDialog("chrome://quickjava/content/options.xul", "", "chrome,toolbar"); - }, +showOptions: function() { + window.openDialog("chrome://quickjava/content/options.xul", "", "chrome,toolbar"); +}, // Returns plugin enabled status of plugin(s), whose name matches on aRegEx isEnabled: function(whichIcon) { - if (!Ci) { return false; } //This is not a normal window (example: options dialog) +try +{ + if (typeof(Ci) == 'undefined') { return false; } //This is not a normal window (example: options dialog) if (whichIcon == this.qj_JS) { return this.prefs.getBoolPref("javascript.enabled"); } if (whichIcon == this.qj_AI) { return (this.prefs.getCharPref("image.animation_mode") == "normal"); } if (whichIcon == this.qj_C) { return (this.prefs.getIntPref("network.cookie.cookieBehavior") != 2); } if (whichIcon == this.qj_I) { return (this.prefs.getIntPref("permissions.default.image") == 1); } - if (whichIcon == this.qj_CS) { return !(getMarkupDocumentViewer().authorStyleDisabled); } + if (whichIcon == this.qj_WebGL) { return this.prefs.getBoolPref("webgl.disabled") == false; } + if (whichIcon == this.qj_WebRTC) { return this.prefs.getBoolPref("media.peerconnection.enabled"); } + + if (whichIcon == this.qj_CS) { + let styleSheetInfo = gPageStyleMenu._getStyleSheetInfo(gBrowser.selectedBrowser); + let styleSheets = styleSheetInfo.filteredStyleSheets; + return !(styleSheetInfo.authorStyleDisabled); + } + if (whichIcon == this.qj_P) { return (this.prefs.getIntPref("network.proxy.type") != 0); } var aRegEx = this.GetRegEx(whichIcon); @@ -599,6 +686,7 @@ isEnabled: function(whichIcon) { } } } +} catch (e) { try { this.handleError(e); } catch (e) {} } return 0; }, @@ -609,6 +697,8 @@ isEnabledAllFavorites: function() && (!this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_J) || this.isEnabled(this.qj_J)) && (!this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_JS) || this.isEnabled(this.qj_JS)) && (!this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_F) || this.isEnabled(this.qj_F)) + && (!this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_WebGL) || this.isEnabled(this.qj_WebGL)) + && (!this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_WebRTC) || this.isEnabled(this.qj_WebRTC)) && (!this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_SL) || this.isEnabled(this.qj_SL)) && (!this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_AI) || this.isEnabled(this.qj_AI)) && (!this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_C) || this.isEnabled(this.qj_C)) @@ -622,6 +712,8 @@ isEnabledAnyFavorites: function() || (this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_J) && this.isEnabled(this.qj_J)) || (this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_JS) && this.isEnabled(this.qj_JS)) || (this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_F) && this.isEnabled(this.qj_F)) + || (this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_WebGL) && this.isEnabled(this.qj_WebGL)) + || (this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_WebRTC) && this.isEnabled(this.qj_WebRTC)) || (this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_SL) && this.isEnabled(this.qj_SL)) || (this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_AI) && this.isEnabled(this.qj_AI)) || (this.prefs.getBoolPref(this.qj_Prefix_Pref_Fav + this.qj_C) && this.isEnabled(this.qj_C)) @@ -634,7 +726,8 @@ updateCustomStyle: function() { for(var i = 0; i < document.styleSheets.length;i++) { - if(document.styleSheets[i].href.match(".*quickjava\.css$")) + if (document.styleSheets[i].href + && document.styleSheets[i].href.match(".*quickjava\.css$")) { this.myStyleSheet = document.styleSheets[i]; } @@ -687,10 +780,31 @@ updateCustomStyle: function() } }, +consoleLog: function(msg, stackTrace) + { + if (window.console && window.console.log) { window.console.log('[QuickJava]: ' + msg); if (stackTrace && window.console.trace) { window.console.trace(); } } + }, + onLoadDetails: function(evt) { + gBrowser.tabContainer.addEventListener("TabSelect", thatoneguydotnet.QuickJava.newTabSelected, false) gBrowser.tabContainer.addEventListener("TabOpen", thatoneguydotnet.QuickJava.newTabOpened, false) - window.addEventListener("aftercustomization", thatoneguydotnet.QuickJava.updateIcons, false); + this.CUIListener = { + handler: function(aWidgetId) { + if (aWidgetId.indexOf('QuickJava') >= 0) { + thatoneguydotnet.QuickJava.consoleLog(aWidgetId); + /* Our toolbar icons may have been added or removed to/from a toolbar or panel */ + thatoneguydotnet.QuickJava.updateIcons(); + } + }, + onWidgetAdded: function(aWidgetId) { this.handler(aWidgetId); }, + onWidgetRemoved: function(aWidgetId) { this.handler(aWidgetId); }, + onAreaNodeRegistered: function() { this.handler('QuickJava'); }, + onAreaNodeUnregstered: function() { this.handler('QuickJava'); } + }; + Components.utils.import("resource:///modules/CustomizableUI.jsm"); + CustomizableUI.addListener(this.CUIListener); + this.PluginObserver = { register: function() @@ -744,6 +858,7 @@ onLoadDetails: function(evt) } else if (aData == "javascript.enabled" || aData == "permissions.default.image" || aData == "network.proxy.type" || aData == "network.cookie.cookieBehavior" || aData == "image.animation_mode" + || aData == "webgl.disabled" || aData == "media.peerconnection.enabled" || (aData.match("^"+this.QuickJavaObject.qj_Prefix_Pref)==this.QuickJavaObject.qj_Prefix_Pref)) { thatoneguydotnet.QuickJava.updateIcons(); @@ -758,12 +873,121 @@ onLoadDetails: function(evt) onUnload: function(evt) { - this.PrefObserver.unregister(); - this.PluginObserver.unregister(); - window.removeEventListener("aftercustomization", thatoneguydotnet.QuickJava.updateIcons, false); - gBrowser.tabContainer.removeEventListener("TabOpen", thatoneguydotnet.QuickJava.newTabOpened, false) + try + { + if (typeof(Ci) == 'undefined') { return false; } //This is not a normal window (example: options dialog) + if (thatoneguydotnet.QuickJava.PrefObserver && thatoneguydotnet.QuickJava.PrefObserver.unregister) { thatoneguydotnet.QuickJava.PrefObserver.unregister(); } + if (thatoneguydotnet.QuickJava.PluginObserver && thatoneguydotnet.QuickJava.PluginObserver.unregister) { thatoneguydotnet.QuickJava.PluginObserver.unregister(); } + if (gBrowser) { gBrowser.tabContainer.removeEventListener("TabOpen", thatoneguydotnet.QuickJava.newTabOpened, false); } + if (gBrowser) { gBrowser.tabContainer.removeEventListener("TabSelect", thatoneguydotnet.QuickJava.newTabSelected, false); } + if (this.CUIListener) { CustomizableUI.removeListener(this.CUIListener); } + } catch (e) { try { this.handleError(e); } catch (e) {} } + }, + +movePreferences: function() + { + if (this.prefs.getPrefType(this.qj_Prefix_PrefOld + '.curVersion')) + { + this.consoleLog('QuickJava moving preferences'); + + this.movePreference(this.qj_Prefix_PrefOld + '.curVersion', false, true, false); // Bool,Char,Int + + /* which icons are hidden in status/addon bar */ + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.JavaScript', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.Java', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.Flash', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.WebGL', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.WebRTC', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.Silverlight', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.AnimatedImage', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.Cookies', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.Images', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.CSS', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.hidestatus.Proxy', true, false, false); // Bool,Char,Int + + /* 0 = initial luanch, 1 = new window, 2 = new tab */ + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.type', false, false, true); // Bool,Char,Int + + /* 0 = no change, 1 = enabled, 2 = disabled */ + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.JavaScript', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.Java', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.Flash', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.WebGL', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.WebRTC', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.Silverlight', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.AnimatedImage', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.Cookies', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.Images', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.CSS', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.startupStatus.Proxy', false, false, true); // Bool,Char,Int + + /* which icons are visible in the favorites menu button */ + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.JavaScript', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.Java', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.Flash', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.WebGL', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.WebRTC', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.Silverlight', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.AnimatedImage', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.Cookies', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.Images', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.CSS', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.Proxy', true, false, false); // Bool,Char,Int + + /* What to display/do when some favories are enabled and some are different. 1 = Enabled, 0 = Disabled */ + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.differentDisplay', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.favorites.differentToggle', false, false, true); // Bool,Char,Int + + /* which icons cause a reload of the page when they are changed */ + this.movePreference(this.qj_Prefix_PrefOld + '.reload.JavaScript', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.reload.Java', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.reload.Flash', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.reload.WebGL', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.reload.WebRTC', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.reload.Silverlight', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.reload.AnimatedImage', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.reload.Cookies', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.reload.Images', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.reload.CSS', true, false, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.reload.Proxy', true, false, false); // Bool,Char,Int + + this.movePreference(this.qj_Prefix_PrefOld + '.priorvalue.Proxy', false, false, true); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.priorvalue.Cookie', false, false, true); // Bool,Char,Int + + this.movePreference(this.qj_Prefix_PrefOld + '.enabledState.ClickToPlay', true, false, false); // Bool,Char,Int + + this.movePreference(this.qj_Prefix_PrefOld + '.regex.Java', false, true, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.regex.Flash', false, true, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.regex.Silverlight', false, true, false); // Bool,Char,Int + + this.movePreference(this.qj_Prefix_PrefOld + '.custombuttonstyle.default', false, true, false); // Bool,Char,Int + this.movePreference(this.qj_Prefix_PrefOld + '.custombuttonstyle.enabled', false, true, false); // Bool,Char,Int + } }, + +movePreference : function(oldPrefName, isBool, isChar, isInt) + { + if (this.prefs.getPrefType(oldPrefName))//this.qj_Prefix_PrefOld + '.curVersion')) + { + var newPrefName = oldPrefName.replace(this.qj_Prefix_PrefOld,this.qj_Prefix_Pref); + this.consoleLog('Move ' + oldPrefName + ' to ' + newPrefName); + if (isBool) + { + this.prefs.setBoolPref(newPrefName, this.prefs.getBoolPref(oldPrefName)); + } + else if (isChar) + { + this.prefs.setCharPref(newPrefName, this.prefs.getCharPref(oldPrefName)); + } + else if (isInt) + { + this.prefs.setIntPref(newPrefName, this.prefs.getIntPref(oldPrefName)); + } + this.prefs.clearUserPref(oldPrefName); + } + } }; +thatoneguydotnet.QuickJava.initQJ(); window.addEventListener('load', function(e) { thatoneguydotnet.QuickJava.onLoad(e); },false); -window.addEventListener('unload',function(e) { thatoneguydotnet.QuickJava.onUnload(e); },false); +window.addEventListener('unload',function(e) { thatoneguydotnet.QuickJava.onUnload(e); },false); \ No newline at end of file diff --git a/content/browserOverlay.xul b/content/browserOverlay.xul index 1eb1853..54c6cf3 100644 --- a/content/browserOverlay.xul +++ b/content/browserOverlay.xul @@ -6,7 +6,7 @@