Permalink
Browse files

Merge branch 'master' (early part) into staging

  • Loading branch information...
2 parents 7524346 + 3e2f00c commit c8ea0557be9dfc3fe91097dd8b8db4fc6d089faa @erikvold erikvold committed Mar 23, 2011
Showing with 913 additions and 299 deletions.
  1. +2 −0 .gitignore
  2. +1 −1 {extension → }/LICENSE.txt
  3. +3 −0 blocklist.json
  4. +9 −6 build.sh
  5. +20 −9 extension/components/scriptish.js
  6. +4 −0 extension/content/install.xul
  7. +2 −5 extension/content/js/addonstab.js
  8. +11 −8 extension/content/js/browser.js
  9. +11 −22 extension/content/js/install.js
  10. +9 −0 extension/content/js/script-options.js
  11. +4 −0 extension/content/script-options.xul
  12. +8 −1 extension/defaults/preferences/scriptish.js
  13. +2 −2 extension/install.rdf
  14. +5 −3 extension/locale/en-US/scriptish.properties
  15. +2 −2 extension/locale/ja-JP/scriptish.properties
  16. +46 −20 extension/locale/ru-RU/scriptish.properties
  17. +21 −9 extension/modules/api.js
  18. +4 −6 extension/modules/api/GM_Resources.js
  19. +26 −5 extension/modules/api/GM_xmlhttpRequester.js
  20. +147 −16 extension/modules/config/config.js
  21. +10 −1 extension/modules/constants.js
  22. +2 −3 extension/modules/content/browser.js
  23. +71 −9 extension/modules/menucommander.js
  24. +2 −2 extension/modules/prefmanager.js
  25. +302 −58 extension/modules/script/script.js
  26. +67 −23 extension/modules/script/scriptdownloader.js
  27. +10 −1 extension/modules/script/scripticon.js
  28. +1 −0 extension/modules/script/scriptinstaller.js
  29. +33 −2 extension/modules/scriptish.js
  30. +14 −1 extension/modules/third-party/Scriptish_openFolder.js
  31. +5 −7 extension/modules/utils/Scriptish_convert2RegExp.js
  32. +16 −0 extension/modules/utils/Scriptish_getTLDURL.js
  33. +0 −19 extension/modules/utils/Scriptish_hitch.js
  34. +1 −3 extension/modules/utils/Scriptish_installUri.js
  35. +0 −30 extension/modules/utils/Scriptish_isGreasemonkeyable.js
  36. +30 −0 extension/modules/utils/Scriptish_memoize.js
  37. +6 −3 extension/modules/utils/Scriptish_notification.js
  38. +0 −9 extension/modules/utils/Scriptish_openManager.js
  39. +0 −7 extension/modules/utils/Scriptish_parseScriptName.js
  40. +6 −6 update.rdf
View
@@ -6,3 +6,5 @@
BASE.*
LOCAL.*
REMOTE.*
+build
+
@@ -21,4 +21,4 @@ http://creativecommons.org/licenses/by-sa/3.0/
The uso_medium.png icon contained within Scriptish is the property of
UserScripts.org http://userscripts.org and is being used with their consent
-License copies can be found in the license directory.
+License copies can be found in the extension/license/ directory.
View
@@ -0,0 +1,3 @@
+{
+ "uso": [20145, 35611, 38017, 68219]
+}
View
@@ -12,14 +12,18 @@ XPI="scriptish-$VER.xpi"
# Copy base structure to a temporary build directory and change to it
echo "Creating working directory ..."
-cd extension
rm -rf build
mkdir build
+cp LICENSE.txt build/
+cd extension
cp -r \
- chrome.manifest components content defaults install.rdf license LICENSE.txt \
+ chrome.manifest components content defaults install.rdf license \
locale modules skin \
- build/
-cd build
+ ../build/
+cd ../build
+
+sed -e 's/extension\/license/license/g' LICENSE.txt > LICENSE.txt.$$
+mv LICENSE.txt.$$ LICENSE.txt
if [ "amo" = "$1" ]; then
(sed -e 's/<em\:update.*//g' install.rdf > install.rdf.$$ &&
@@ -35,9 +39,8 @@ find . -depth -name '#*' -exec rm -rf "{}" \;
find . -depth -name '.DS_Store' -exec rm "{}" \;
echo "Creating $XPI ..."
-zip -qr9XD "../../$XPI" *
+zip -qr9XD "../$XPI" *
echo "Cleaning up temporary files ..."
cd ..
rm -rf build
-cd ..
@@ -11,7 +11,6 @@ Cu.import("resource://scriptish/logging.js");
Cu.import("resource://scriptish/scriptish.js");
Cu.import("resource://scriptish/third-party/Timer.js");
Cu.import("resource://scriptish/utils/Scriptish_getFirebugConsole.js");
-Cu.import("resource://scriptish/utils/Scriptish_hitch.js");
Cu.import("resource://scriptish/utils/Scriptish_alert.js");
Cu.import("resource://scriptish/utils/Scriptish_getBrowserForContentWindow.js");
@@ -80,7 +79,7 @@ ScriptishService.prototype = {
let gmBrowserUI = chromeWin.Scriptish_BrowserUI;
let gBrowser = chromeWin.gBrowser;
- let href = safeWin.location.href;
+ let href = safeWin.location.href || safeWin.frameElement.src;
// Show the scriptish install banner if the user is navigating to a .user.js
// file in a top-level tab. If the file was previously cached it might have
// been given a number after .user, like gmScript.user-12.js
@@ -122,7 +121,7 @@ ScriptishService.prototype = {
case "document-idle":
if (2 > rdyStateIdx) {
safeWin.addEventListener(
- "DOMContentLoaded", function() timeout(inject, 0), true);
+ "DOMContentLoaded", function() timeout(inject), true);
return;
}
break;
@@ -136,7 +135,7 @@ ScriptishService.prototype = {
inject();
});
- // if the focused tab's window is loading, then attach menuCommaander
+ // if the focused tab's window is loading, then attach menuCommander
if (safeWin === gBrowser.selectedBrowser.contentWindow) {
if (gmBrowserUI.currentMenuCommander)
gmBrowserUI.currentMenuCommander.detach();
@@ -175,21 +174,33 @@ ScriptishService.prototype = {
// inject @run-at document-start scripts
self.injectScripts(scripts["document-start"], href, safeWin, chromeWin);
- safeWin.addEventListener("pagehide", function(e) {
- winClosed = true;
- self.docUnload(safeWin, gmBrowserUI);
+ safeWin.addEventListener("pagehide", function(aEvt) {
+ if (safeWin.frameElement
+ && aEvt.target.location.href == "about:blank"
+ && safeWin.frameElement.src != "about:blank") return; // see bug 643181
+ winClosed = self.docUnload(aEvt, safeWin, gmBrowserUI);
}, false);
},
- docUnload: function(aWin, aGMBrowserUI) {
+
+ docUnload: function(aEvt, aWin, aGMBrowserUI) {
+ // if persisted then the page/frame is bfcached, so unload will occur later
+ if (aEvt.persisted) return false;
+
+ // Ignore if we are inside a frame.
+ // This is okay since there will be no menuCommanders to remove.
+ if (aWin.frameElement) return true;
+
let menuCmders = aGMBrowserUI.menuCommanders;
- if (!menuCmders || 0 == menuCmders.length) return;
+ if (!menuCmders || 0 == menuCmders.length) return true;
+
let curMenuCmder = this.currentMenuCommander;
for (let [i, item] in Iterator(menuCmders)) {
if (item.win !== aWin) continue;
if (item.commander === curMenuCmder) curMenuCmder = curMenuCmder.detach();
menuCmders.splice(i, 1);
break;
}
+ return true;
},
shouldLoad: function(ct, cl, org, ctx, mt, ext) {
@@ -23,6 +23,10 @@
<description id="scriptDescription" flex="1"/>
</hbox>
<vbox id="itemBox" flex="1">
+ <vbox id="domains">
+ <label id="domains-label"/>
+ <description id="domains-desc"/>
+ </vbox>
<vbox id="matches">
<label id="matches-label"/>
<description id="matches-desc"/>
@@ -1,12 +1,9 @@
-
-(function($, tools){
+(function($, tools) {
var Cu = Components.utils;
Cu.import("resource://scriptish/constants.js", tools);
Cu.import("resource://scriptish/prefmanager.js");
Cu.import("resource://scriptish/logging.js");
-Cu.import("resource://scriptish/addonprovider.js");
Cu.import("resource://scriptish/scriptish.js");
-Cu.import("resource://scriptish/utils/Scriptish_hitch.js");
Cu.import("resource://scriptish/utils/Scriptish_stringBundle.js");
Cu.import("resource://scriptish/utils/Scriptish_ExtendedStringBundle.js");
Cu.import("resource://scriptish/utils/Scriptish_openInEditor.js");
@@ -69,6 +66,6 @@ window.addEventListener("load", function() {
}, false);
window.addEventListener(
- "unload", Scriptish_hitch(Scriptish.config, "uninstallScripts"), false);
+ "unload", Scriptish.config.uninstallScripts.bind(Scriptish.config), false);
})(function(aID) document.getElementById(aID), {});
@@ -8,7 +8,6 @@ var Scriptish_BrowserUIM;
inc("resource://scriptish/content/browser.js");
inc("resource://scriptish/prefmanager.js");
inc("resource://scriptish/scriptish.js");
-inc("resource://scriptish/utils/Scriptish_hitch.js", tools);
inc("resource://scriptish/utils/Scriptish_stringBundle.js");
inc("resource://scriptish/utils/Scriptish_openInEditor.js");
inc("resource://scriptish/utils/Scriptish_getURLsForContentWindow.js");
@@ -21,7 +20,6 @@ var Ci = tools.Ci;
var Services = tools.Services;
var gmSvc = Services.scriptish;
var $ = function(aID) document.getElementById(aID);
-function hitch() tools.Scriptish_hitch.apply(null, arguments);
Scriptish_BrowserUI.QueryInterface = tools.XPCOMUtils.generateQI([
Ci.nsISupports, Ci.nsISupportsWeakReference, Ci.nsIWebProgressListener]);
@@ -134,12 +132,12 @@ Scriptish_BrowserUI.chromeLoad = function(e) {
}, false)
// update visual status when enabled state changes
- this.statusWatcher = hitch(Scriptish_BrowserUIM, "refreshStatus");
+ this.statusWatcher = Scriptish_BrowserUIM.refreshStatus.bind(Scriptish_BrowserUIM);
Scriptish_prefRoot.watch("enabled", this.statusWatcher);
// hook on to context menu popup event
$("contentAreaContextMenu").addEventListener(
- "popupshowing", hitch(this, "contextMenuShowing"), false);
+ "popupshowing", this.contextMenuShowing.bind(this), false);
// this gives us onLocationChange
gBrowser.addProgressListener(this, Ci.nsIWebProgress.NOTIFY_LOCATION);
@@ -153,11 +151,16 @@ Scriptish_BrowserUI.chromeLoad = function(e) {
Scriptish_BrowserUI.registerMenuCommand = function(menuCommand) {
var commander = this.getCommander(menuCommand.window);
- commander.registerMenuCommand(
+ return commander.registerMenuCommand(
menuCommand.name, menuCommand.doCommand, menuCommand.accelKey,
menuCommand.accelModifiers, menuCommand.accessKey);
}
+Scriptish_BrowserUI.unregisterMenuCommand = function(commandUUID, aWin) {
+ var commander = this.getCommander(aWin);
+ return commander.unregisterMenuCommand(commandUUID);
+}
+
/**
* Shows the install banner across the top of the tab that is displayed when
@@ -183,7 +186,7 @@ Scriptish_BrowserUI.showInstallBanner = function(browser) {
[{label: Scriptish_stringBundle("greeting.btn"),
accessKey: Scriptish_stringBundle("greeting.btn.ak"),
popup: null,
- callback: hitch(this, "installCurrentScript")
+ callback: this.installCurrentScript.bind(this)
}]
);
}
@@ -296,8 +299,8 @@ Scriptish_BrowserUI.onStatusChange = function(a,b,c,d){};
Scriptish_BrowserUI.onSecurityChange = function(a,b,c){};
Scriptish_BrowserUI.onLinkIconAvailable = function(a){};
-window.addEventListener("load", hitch(Scriptish_BrowserUI, "chromeLoad"), false);
-window.addEventListener("unload", hitch(Scriptish_BrowserUI, "chromeUnload"), false);
+window.addEventListener("load", Scriptish_BrowserUI.chromeLoad.bind(Scriptish_BrowserUI), false);
+window.addEventListener("unload", Scriptish_BrowserUI.chromeUnload.bind(Scriptish_BrowserUI), false);
})(Components.utils.import, {})
/**
@@ -18,26 +18,25 @@ let on = addEventListener;
function setupIncludes(type, items) {
if (!items.length) return;
- let [box, desc, list, str] = [$(type), $(type + "-desc"), $nHTML("ul"), ""];
+ let [list, str] = [$nHTML("ul"), ""];
for (let [, i] in Iterator(items)) {
switch(type) {
case "matches":
- str = i.pattern;
+ i = i.pattern;
break
case "resources":
- str = i.match(valueSplitter)[2];
+ i = i.match(valueSplitter)[2];
break;
- default:
- str = i;
}
- list.appendChild($nHTML("li", str));
+ list.appendChild($nHTML("li", i));
}
- desc.appendChild(list);
- box.setAttribute("class", "display");
+ $(type + "-desc").appendChild(list);
+ $(type).setAttribute("class", "display");
+ $(type + "-label").setAttribute("value", Scriptish_stringBundle("install." + type)); // l10n
}
function cleanup() scriptDownloader.cleanupTempFiles();
-function delayedClose() setTimeout(close, 0);
+function delayedClose() timeout(close);
/* Main */
@@ -49,9 +48,9 @@ on("load", function() {
let headers = script.getScriptHeader();
// setup lists
- setupIncludes("matches", script.matches);
- setupIncludes("includes", script.includes);
- setupIncludes("excludes", script.excludes);
+ ["domains", "matches", "includes", "excludes"].forEach(function(i) {
+ setupIncludes(i, script[i]);
+ });
setupIncludes("requires", headers.require || []);
setupIncludes("resources", headers.resource || []);
@@ -62,16 +61,6 @@ on("load", function() {
dialog.getButton("cancel").focus();
// setup other l10n
- $("matches-label").setAttribute("value",
- Scriptish_stringBundle("install.matches"));
- $("includes-label").setAttribute("value",
- Scriptish_stringBundle("install.runsOn"));
- $("excludes-label").setAttribute("value",
- Scriptish_stringBundle("install.butNotOn"));
- $("requires-label").setAttribute("value",
- Scriptish_stringBundle("install.requires"));
- $("resources-label").setAttribute("value",
- Scriptish_stringBundle("install.resources"));
$("warning1").appendChild($t(Scriptish_stringBundle("install.warning1")));
$("warning2").appendChild($t(Scriptish_stringBundle("install.warning2")));
@@ -26,6 +26,10 @@ window.addEventListener("load", function() {
$("includes").value = script.getUserIncStr();
$("excludes").value = script.getUserIncStr("exclude");
+ let tmp = $("disableScriptIncludes");
+ tmp.setAttribute("label", Scriptish_stringBundle("scriptOptions.disableScriptIncludes"));
+ tmp.checked = script.includesDisabled;
+
return true;
}, false);
@@ -37,7 +41,12 @@ function doSave() {
script.user_includes = postInc.match(/.+/g);
script.user_excludes = postExc.match(/.+/g);
Scriptish.config._save();
+
+ // display modified notification
+ script.modificationProcess(true);
}
+ script.includesDisabled = $("disableScriptIncludes").checked;
+
return true;
}
@@ -16,5 +16,9 @@
<label id="excludes-label" control="excludes"/>
<textbox id="excludes" multiline="true" rows="4" cols="60"/>
+
+ <separator class="thin"/>
+
+ <checkbox id="disableScriptIncludes"/>
</vbox>
</dialog>
@@ -1,8 +1,15 @@
pref("extensions.scriptish.aboutIsGreaseable", false);
pref("extensions.scriptish.fileIsGreaseable", false);
pref("extensions.scriptish.unmhtIsGreaseable", false);
-pref("extensions.scriptish.enableScriptRefreshing", true);
+pref("extensions.scriptish.blocklist.enabled", true);
+pref("extensions.scriptish.blocklist.interval", 86400);
+pref("extensions.scriptish.blocklist.lastFetch", 0);
+pref("extensions.scriptish.blocklist.url", "https://github.com/erikvold/scriptish/raw/master/blocklist.json");
pref("extensions.scriptish.enableCopyDownloadURL", false);
+pref("extensions.scriptish.enableScriptRefreshing", true);
pref("extensions.scriptish.uninstallPreferences", true);
+pref("extensions.scriptish.update.requireBuiltInCerts", true);
+pref("extensions.scriptish.update.uso.interval", 86400);
+pref("extensions.scriptish.update.uso.lastFetch", 0);
pref("extensions.scriptish.useDefaultLocale", false);
pref("extensions.scriptish.useDownloadURLForUpdateURL", false);
View
@@ -20,7 +20,7 @@
<em:name>Scriptish</em:name>
<em:description>A Script Extension Manager for Firefox</em:description>
- <em:version>0.1b9</em:version>
+ <em:version>0.1</em:version>
<em:creator>Erik Vold; http://erikvold.com/</em:creator>
<em:homepageURL>http://github.com/erikvold/scriptish</em:homepageURL>
<em:optionsURL>chrome://scriptish/content/options.xul</em:optionsURL>
@@ -71,7 +71,7 @@
<Description>
<em:id>{92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}</em:id>
<em:minVersion>2.1a3</em:minVersion>
- <em:maxVersion>2.1b2</em:maxVersion>
+ <em:maxVersion>2.1b3pre</em:maxVersion>
</Description>
</em:targetApplication>
</Description>
@@ -35,12 +35,13 @@ error.script.loading=Error loading user script
greeting.btn=Install
greeting.btn.ak=I
greeting.msg=This is a user script. Click install to start using it.
+install.domains=domains:
+install.matches=matches:
+install.includes=runs on:
+install.excludes=does not run on:
install.requires=requires:
install.resources=resources:
-install.butNotOn=does not run on:
install.installButton=Install
-install.matches=matches:
-install.runsOn=runs on:
install.showScriptSource=Show Script Source
install.title=User Script Installation
install.warning1=Malicious scripts can violate your privacy and act on your behalf without your knowledge.
@@ -74,6 +75,7 @@ openFolder=Open Folder
openFolder.ak=O
scriptOptions.includes=User Includes:
scriptOptions.excludes=User Excludes:
+scriptOptions.disableScriptIncludes=Disable this script's include patterns and only use the user defined ones.
options=Options
options.excludes=Global Excludes
options.addonManager=Add-on Manager
@@ -33,10 +33,10 @@ error.script.loading=ユーザースクリプトのロード中にエラーが
greeting.btn=インストール
greeting.btn.ak=I
greeting.msg=ユーザースクリプトです。使用を開始するにはクリックして下さい。
-install.butNotOn=スクリプト無効:
+install.excludes=スクリプト無効:
install.installButton=インストール
install.matches=一致:
-install.runsOn=スクリプト有効:
+install.includes=スクリプト有効:
install.showScriptSource=スクリプトのソースを表示
install.title=ユーザースクリプトのインストール
install.warning1=悪意のあるスクリプトがプライバシーを侵害して知らないうちに動作するかもしれません。
Oops, something went wrong.

0 comments on commit c8ea055

Please sign in to comment.