From f6f9dd08ab311129cc0e00552773223c31dff3fd Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Thu, 14 Jul 2011 16:44:00 -0700 Subject: [PATCH 01/35] Closes #215 Implemented @developer --- extension/modules/script/script.js | 39 +++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/extension/modules/script/script.js b/extension/modules/script/script.js index 2c999d90..eb9dbdce 100644 --- a/extension/modules/script/script.js +++ b/extension/modules/script/script.js @@ -70,6 +70,7 @@ function Script(config) { this._prefroot = null; this._author = null; this._applyBackgroundUpdates = defaultAutoUpdateState; + this._developers = []; this._contributors = []; this._description = null; this._version = null; @@ -388,14 +389,25 @@ Script.prototype = { this._creator = this._author; } }, + get developers() { + var devs = this._developers; + if (!AddonManagerPrivate.AddonAuthor) return devs; + var ary = []; + for (var i = devs.length-1; ~i; i--) + ary.unshift(new AddonManagerPrivate.AddonAuthor(devs[i])); + return ary; + }, get contributors() { - if (!AddonManagerPrivate.AddonAuthor) return this._contributors; - var contributors = []; - for (var i = this._contributors.length-1; i >= 0; i--) { - contributors.unshift( - new AddonManagerPrivate.AddonAuthor(this._contributors[i])); - } - return contributors; + var contribs = this._contributors; + if (!AddonManagerPrivate.AddonAuthor) return contribs; + var ary = []; + for (var i = contribs.length-1; ~i; i--) + ary.unshift(new AddonManagerPrivate.AddonAuthor(contribs[i])); + return ary; + }, + addDeveloper: function(aVal) { + if (!aVal) return; + this._developers.push(aVal); }, addContributor: function(aContributor) { if (!aContributor) return; @@ -686,6 +698,7 @@ Script.prototype = { this._name = newScript._name; this._namespace = newScript._namespace; this.author = newScript._author; + this._developers = newScript._developers; this._contributors = newScript._contributors; this._description = newScript._description; this._jsversion = newScript._jsversion; @@ -739,7 +752,6 @@ Script.prototype = { }, toJSON: function() ({ - contributors: this._contributors, domains: this.domains, includes: this._includes.patterns, excludes: this._excludes.patterns, @@ -763,6 +775,8 @@ Script.prototype = { name: this.name, namespace: this.namespace, author: this._author, + developers: this._developers, + contributors: this._contributors, blocklistState: this.blocklistState, description: this._description, version: this._version, @@ -907,6 +921,10 @@ Script.parse = function Script_parse(aConfig, aSource, aURI, aUpdateScript) { script.author = value; continue; } + // nobreak + case "developer": + script.addDeveloper(value); + continue; case "contributor": script.addContributor(value); continue; @@ -1134,7 +1152,10 @@ Script.loadFromJSON = function(aConfig, aSkeleton) { script._noframes = aSkeleton.noframes; script.domains = aSkeleton.domains; - aSkeleton.contributors.forEach(script.addContributor.bind(script)); + if (aSkeleton.developers) + aSkeleton.developers.forEach(script.addDeveloper.bind(script)); + if (aSkeleton.contributors) + aSkeleton.contributors.forEach(script.addContributor.bind(script)); script.addInclude(aSkeleton.includes); script.addExclude(aSkeleton.excludes); script.addInclude(aSkeleton.user_includes, true); From 573f36e61f46be9a91502de0f5607949c9c87d1c Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Thu, 14 Jul 2011 17:16:22 -0700 Subject: [PATCH 02/35] copying and pasting startButton.xml from Firebug --- .../content/third-party/firebug/license.txt | 30 +++++++++++++++++++ .../third-party/firebug/startButton.xml | 27 +++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100755 extension/content/third-party/firebug/license.txt create mode 100755 extension/content/third-party/firebug/startButton.xml diff --git a/extension/content/third-party/firebug/license.txt b/extension/content/third-party/firebug/license.txt new file mode 100755 index 00000000..ce3c765f --- /dev/null +++ b/extension/content/third-party/firebug/license.txt @@ -0,0 +1,30 @@ +Software License Agreement (BSD License) + +Copyright (c) 2007, Parakey Inc. +All rights reserved. + +Redistribution and use of this software in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +* Redistributions of source code must retain the above + copyright notice, this list of conditions and the + following disclaimer. + +* Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the + following disclaimer in the documentation and/or other + materials provided with the distribution. + +* Neither the name of Parakey Inc. nor the names of its + contributors may be used to endorse or promote products + derived from this software without specific prior + written permission of Parakey Inc. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND +FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/extension/content/third-party/firebug/startButton.xml b/extension/content/third-party/firebug/startButton.xml new file mode 100755 index 00000000..741f24d0 --- /dev/null +++ b/extension/content/third-party/firebug/startButton.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + From d624ab1847d580bc48e8fc905a2448bd08b81104 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Thu, 14 Jul 2011 17:23:44 -0700 Subject: [PATCH 03/35] displaying the badge beside the scriptish button --- extension/content/browser.xul | 1 + .../third-party/firebug/startButton.xml | 36 ++++++++----------- extension/skin/browser.css | 1 + 3 files changed, 17 insertions(+), 21 deletions(-) diff --git a/extension/content/browser.xul b/extension/content/browser.xul index 02f3480a..e0c8de4c 100644 --- a/extension/content/browser.xul +++ b/extension/content/browser.xul @@ -41,6 +41,7 @@ observes="scriptish-button-brd" type="menu-button" context="" + scriptCount="1" class="toolbarbutton-1 chromeclass-toolbar-additional" label="Scriptish"> diff --git a/extension/content/third-party/firebug/startButton.xml b/extension/content/third-party/firebug/startButton.xml index 741f24d0..d2d6f224 100755 --- a/extension/content/third-party/firebug/startButton.xml +++ b/extension/content/third-party/firebug/startButton.xml @@ -1,27 +1,21 @@ - - - - - - - - - - - - - - - - + + + + + + + + + + + diff --git a/extension/skin/browser.css b/extension/skin/browser.css index 4ac1913e..5ada41fb 100644 --- a/extension/skin/browser.css +++ b/extension/skin/browser.css @@ -1,5 +1,6 @@ #scriptish-button { -moz-box-orient: horizontal; + -moz-binding: url("chrome://scriptish/content/third-party/firebug/startButton.xml#scriptish-button");' list-style-image: url("chrome://scriptish/skin/scriptish24.png"); } From 8809c379f5fe81c45cfe56fbc82e75164b6ceff2 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 15 Jul 2011 10:18:57 -0700 Subject: [PATCH 04/35] adding styling for the badge from Firebug --- extension/chrome.manifest | 1 + extension/content/browser.xul | 2 + .../third-party/firebug/startButton.css | 62 +++++++++++++++++++ extension/skin/browser.css | 2 +- 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100755 extension/content/third-party/firebug/startButton.css diff --git a/extension/chrome.manifest b/extension/chrome.manifest index 96e57567..12355516 100644 --- a/extension/chrome.manifest +++ b/extension/chrome.manifest @@ -9,6 +9,7 @@ content scriptish content/ resource scriptish modules/ skin scriptish classic/1.0 skin/ style chrome://global/content/customizeToolbar.xul chrome://scriptish/skin/browser.css +style chrome://global/content/customizeToolbar.xul chrome://scriptish/content/third-party/firebug/startButton.css overlay chrome://browser/content/browser.xul chrome://scriptish/content/browser.xul overlay chrome://browser/content/scratchpad.xul chrome://scriptish/content/scratchpad.xul diff --git a/extension/content/browser.xul b/extension/content/browser.xul index e0c8de4c..25ed43b9 100644 --- a/extension/content/browser.xul +++ b/extension/content/browser.xul @@ -1,5 +1,6 @@ + @@ -42,6 +43,7 @@ type="menu-button" context="" scriptCount="1" + showScripts="true" class="toolbarbutton-1 chromeclass-toolbar-additional" label="Scriptish"> diff --git a/extension/content/third-party/firebug/startButton.css b/extension/content/third-party/firebug/startButton.css new file mode 100755 index 00000000..16d52ab4 --- /dev/null +++ b/extension/content/third-party/firebug/startButton.css @@ -0,0 +1,62 @@ +#scriptish-button .badge > .label { + -moz-box-sizing: border-box; + /*visibility: hidden;*/ + font-size: 10px; + padding: 0 3px; + line-height: 13px; + font-family: Arial, Helvetica, sans-serif; + text-shadow: 0 0 1px #EEF1F7; + color: #900; + border-radius: 3px; + background-color: rgba(255, 0, 0, 0.9); + box-shadow: inset 0px 0px 1px white; + background-image: -moz-linear-gradient( + center bottom, + #DBE1EB 0%, + #DEE4EB 80%, + #E7EBF3 81% + ); + border-width: 1px; + border-style: solid; + border-color: #B3BBC4 #9DA4AD #868D96 #9DA4AD; + box-shadow: 0 0 1px rgba(255, 255, 255, 0.3) inset, + 0 1px 0 rgba(180, 189, 202, 0.7), + 0 0 3px rgba(153, 0, 0, 0.9); +} + +/* Slightly different positions of the badge for individual toolbars */ +#nav-bar #scriptish-button .badge { + margin: 3px -10px 0 -8px; +} + +#addon-bar #scriptish-button .badge { + margin-top: 1px; +} + +#addon-bar #scriptish-button .badge { + margin-top: 1px; +} + +#TabsToolbar #scriptish-button .badge { + margin-top: 4px; +} + +#toolbar-menubar #scriptish-button .badge { + margin-top: 4px; +} + +/* Error badge (displays an error counter). The badge is only visible if error count + should be displayed */ +#scriptish-button .badge { + /*display: none;*/ +} + +#scriptish-button[showScripts="true"] .badge { + display: block; + -moz-box-sizing: border-box; + margin: 0; +} + +#CustomizeToolbarWindow #wrapper-scriptish-button #scriptish-button .badge { + display: none; +} diff --git a/extension/skin/browser.css b/extension/skin/browser.css index 5ada41fb..21178da1 100644 --- a/extension/skin/browser.css +++ b/extension/skin/browser.css @@ -1,6 +1,6 @@ #scriptish-button { -moz-box-orient: horizontal; - -moz-binding: url("chrome://scriptish/content/third-party/firebug/startButton.xml#scriptish-button");' + -moz-binding: url("chrome://scriptish/content/third-party/firebug/startButton.xml#scriptish-button"); list-style-image: url("chrome://scriptish/skin/scriptish24.png"); } From 08e246fc1bc9c58d6c8800c3b1d6e5cb4b682718 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 15 Jul 2011 10:29:54 -0700 Subject: [PATCH 05/35] hide badge if showScripts!=true and minor style changes --- .../third-party/firebug/startButton.css | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/extension/content/third-party/firebug/startButton.css b/extension/content/third-party/firebug/startButton.css index 16d52ab4..a8cbb651 100755 --- a/extension/content/third-party/firebug/startButton.css +++ b/extension/content/third-party/firebug/startButton.css @@ -1,60 +1,60 @@ #scriptish-button .badge > .label { - -moz-box-sizing: border-box; - /*visibility: hidden;*/ - font-size: 10px; - padding: 0 3px; - line-height: 13px; - font-family: Arial, Helvetica, sans-serif; - text-shadow: 0 0 1px #EEF1F7; - color: #900; - border-radius: 3px; - background-color: rgba(255, 0, 0, 0.9); - box-shadow: inset 0px 0px 1px white; - background-image: -moz-linear-gradient( - center bottom, - #DBE1EB 0%, - #DEE4EB 80%, - #E7EBF3 81% - ); - border-width: 1px; - border-style: solid; - border-color: #B3BBC4 #9DA4AD #868D96 #9DA4AD; - box-shadow: 0 0 1px rgba(255, 255, 255, 0.3) inset, - 0 1px 0 rgba(180, 189, 202, 0.7), - 0 0 3px rgba(153, 0, 0, 0.9); + -moz-box-sizing: border-box; + /*visibility: hidden;*/ + font-size: 10px; + padding: 0 3px; + line-height: 13px; + font-family: Arial, Helvetica, sans-serif; + text-shadow: 0 0 1px #EEF1F7; + color: #900; + border-radius: 3px; + background-color: rgba(255, 0, 0, 0.9); + box-shadow: inset 0px 0px 1px white; + background-image: -moz-linear-gradient( + center bottom, + #DBE1EB 0%, + #DEE4EB 80%, + #E7EBF3 81% + ); + border-width: 1px; + border-style: solid; + border-color: #B3BBC4 #9DA4AD #868D96 #9DA4AD; + box-shadow: 0 0 1px rgba(255, 255, 255, 0.3) inset, + 0 1px 0 rgba(180, 189, 202, 0.7), + 0 0 3px rgba(153, 0, 0, 0.9); } /* Slightly different positions of the badge for individual toolbars */ #nav-bar #scriptish-button .badge { - margin: 3px -10px 0 -8px; + margin: 3px -10px 0 -8px; } #addon-bar #scriptish-button .badge { - margin-top: 1px; + margin-top: 1px; } #addon-bar #scriptish-button .badge { - margin-top: 1px; + margin-top: 1px; } #TabsToolbar #scriptish-button .badge { - margin-top: 4px; + margin-top: 4px; } #toolbar-menubar #scriptish-button .badge { - margin-top: 4px; + margin-top: 4px; } /* Error badge (displays an error counter). The badge is only visible if error count should be displayed */ #scriptish-button .badge { - /*display: none;*/ + display: none; } #scriptish-button[showScripts="true"] .badge { - display: block; - -moz-box-sizing: border-box; - margin: 0; + display: block; + -moz-box-sizing: border-box; + margin: 0; } #CustomizeToolbarWindow #wrapper-scriptish-button #scriptish-button .badge { From cfca58818c64a865f396f11cdf6e76e08fc441b5 Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 15 Jul 2011 11:00:18 -0700 Subject: [PATCH 06/35] displaying the number of enabled scripts for the active tab in the badge --- extension/content/js/browser.js | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/extension/content/js/browser.js b/extension/content/js/browser.js index 63d54fcb..9b55619b 100644 --- a/extension/content/js/browser.js +++ b/extension/content/js/browser.js @@ -51,12 +51,14 @@ Scriptish_BrowserUI.tbBtnSetup = function() { var sbPopUp = $("scriptish-tb-popup-brd"); sbPopUp.setAttribute("onclick", "Scriptish_popupClicked(event);event.stopPropagation();"); - sbPopUp.setAttribute("onpopupshowing", "Scriptish_showPopup(event);"); + sbPopUp.setAttribute("onpopupshowing", "Scriptish_setupPopup();"); // update enabled icon Scriptish_BrowserUIM.refreshStatus(); delete Scriptish_BrowserUI["tbBtnSetup"]; + + Scriptish_setupPopup(); } /** @@ -307,8 +309,10 @@ function Scriptish_popupClicked(aEvt) { /** * Handles a Scriptish menu popup event */ -function Scriptish_showPopup(aEvent) Scriptish.getConfig(function(config) { +function Scriptish_setupPopup() Scriptish.getConfig(function(config) { var $ = function(aID) document.getElementById(aID); + var popup = $("scriptish-tb-popup"); + if (!popup) return; Scriptish_BrowserUI.reattachMenuCmds(); function okURL(url) ( @@ -334,11 +338,10 @@ function Scriptish_showPopup(aEvent) Scriptish.getConfig(function(config) { popup.insertBefore(mi, tail); } - var popup = aEvent.target; var tail = $("scriptish-tb-no-scripts-sep"); // remove all the scripts from the list - for (var i = popup.childNodes.length - 1; i >= 0; i--) { + for (var i = popup.childNodes.length - 1; ~i; i--) { var node = popup.childNodes[i]; if (node.script || node.getAttribute("value") == "hack") popup.removeChild(node); @@ -374,8 +377,13 @@ function Scriptish_showPopup(aEvent) Scriptish.getConfig(function(config) { } runsOnTop.forEach(appendScriptToPopup); + var totalScriptCount = frameScriptLen + runsOnTop.length; + function isEnabled(aScript) aScript.enabled; + var enabledScriptCount = runsOnTop.filter(isEnabled).length + runsFramed.filter(isEnabled).length; + $("scriptish-button").setAttribute("scriptCount", enabledScriptCount); + let (menuitem = $("scriptish-tb-no-scripts")) { - let collapsed = menuitem.collapsed = !!(frameScriptLen + runsOnTop.length); + let collapsed = menuitem.collapsed = !!totalScriptCount; if (collapsed) return; // determine the correct label @@ -388,4 +396,10 @@ function Scriptish_showPopup(aEvent) Scriptish.getConfig(function(config) { label = Scriptish_stringBundle("statusbar.noScripts.notfound"); menuitem.setAttribute("label", label); } -}) +}); + +gBrowser.addProgressListener({ + onLocationChange: function(aProgress, aRequest, aURI) { + Scriptish_setupPopup(); + } +}); From e551e38dc274d6ce94187d94413d8a6c1cef1856 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Fri, 15 Jul 2011 06:02:11 +0200 Subject: [PATCH 07/35] Pass cookies during script install Closes #445 --- extension/modules/script/scriptdownloader.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extension/modules/script/scriptdownloader.js b/extension/modules/script/scriptdownloader.js index 76d1c10f..1332fee3 100644 --- a/extension/modules/script/scriptdownloader.js +++ b/extension/modules/script/scriptdownloader.js @@ -53,6 +53,9 @@ ScriptDownloader.prototype.startDownload = function(bypassCache) { req.channel.notificationCallbacks = new BadCertHandler(!Scriptish_prefRoot.getValue("update.requireBuiltInCerts")); } + if (req.channel instanceof Ci.nsIHttpChannelInternal) { + req.channel.forceAllowThirdPartyCookie = true; + } req.onerror = this.handleErr.bind(this); req.onreadystatechange = this.chkContentTypeB4DL.bind(this); req.onload = this.handleScriptDownloadComplete.bind(this); @@ -201,6 +204,9 @@ ScriptDownloader.prototype.downloadNextDependency = function() { } var sourceChannel = Services.io.newChannelFromURI(sourceUri); + if (sourceChannel instanceof Ci.nsIHttpChannelInternal) { + sourceChannel.forceAllowThirdPartyCookie = true; + } sourceChannel.notificationCallbacks = (this.secure) ? new BadCertHandler(!Scriptish_prefRoot.getValue("update.requireBuiltInCerts")) : new NotificationCallbacks(); From 55fda5b3ad94d51177c9fd8acfef43179c99552a Mon Sep 17 00:00:00 2001 From: Erik Vold Date: Fri, 15 Jul 2011 12:14:59 -0700 Subject: [PATCH 08/35] adding 'install user script' menuitem to about:addons --- extension/content/addonstab.xul | 9 ++++++ extension/content/js/addonstab.js | 30 ++++++++++++++++++- extension/locale/en-US/scriptish.properties | 3 ++ .../modules/utils/Scriptish_getEditor.js | 21 ++++++------- 4 files changed, 50 insertions(+), 13 deletions(-) diff --git a/extension/content/addonstab.xul b/extension/content/addonstab.xul index a1fa7820..3fc3f1c6 100644 --- a/extension/content/addonstab.xul +++ b/extension/content/addonstab.xul @@ -3,6 +3,9 @@