Permalink
Browse files

Merge branch 'master' into issue-524

  • Loading branch information...
2 parents f1b9adf + 08cc211 commit 4d97c6676f8701afd0dadd85ee181633bb636cc8 @supahgreg supahgreg committed Sep 5, 2011
Showing with 403 additions and 128 deletions.
  1. +4 −3 README.md
  2. +14 −3 extension/components/scriptish.js
  3. +15 −5 extension/content/e10s/browser-content.js
  4. +51 −4 extension/content/e10s/browser.js
  5. +3 −1 extension/content/js/install.js
  6. +7 −7 extension/content/tests/testScriptHeaderParse.js
  7. +3 −0 extension/locale/de/scriptish.properties
  8. +3 −0 extension/locale/en-US/scriptish.properties
  9. +3 −0 extension/locale/es-ES/scriptish.properties
  10. +3 −0 extension/locale/ja-JP/scriptish.properties
  11. +3 −0 extension/locale/pt-BR/scriptish.properties
  12. +3 −0 extension/locale/ru-RU/scriptish.properties
  13. +3 −0 extension/locale/sv-SE/scriptish.properties
  14. +3 −0 extension/locale/zh-CN/scriptish.properties
  15. +3 −0 extension/locale/zh-TW/scriptish.properties
  16. +11 −0 extension/modules/addonprovider.js
  17. +37 −37 extension/modules/api.js
  18. +63 −8 extension/modules/manager.js
  19. +5 −39 extension/modules/script/script.js
  20. +36 −16 extension/modules/script/scriptdownloader.js
  21. +2 −0 extension/modules/script/scriptinstaller.js
  22. +4 −2 extension/modules/utils/Scriptish_evalInSandbox.js
  23. +1 −0 extension/modules/utils/Scriptish_getProfileFile.js
  24. +42 −0 extension/modules/utils/Scriptish_getScriptHeader.js
  25. +1 −2 extension/modules/utils/Scriptish_notification.js
  26. +5 −0 extension/modules/utils/Scriptish_openInTab.js
  27. +32 −0 extension/modules/utils/Scriptish_parser.js
  28. +1 −1 extension/modules/utils/Scriptish_popupNotification.js
  29. +1 −0 extension/modules/utils/Scriptish_sendAsyncE10SMessage.js
  30. +41 −0 extension/modules/utils/Scriptish_windowEventTracker.js
View
@@ -3,10 +3,11 @@
Scriptish is a userscript manager for Firefox, forked from Greasemonkey.
-# Requirements
+# Browsers Supported
-* Using Scriptish: Firefox 4+
-* Building an XPI: Unix shell
+* Firefox 4+
+* Fennec 4+
+* Seamonkey 2.1+
# Links
@@ -21,6 +21,7 @@ lazyUtil(this, "isScriptRunnable");
lazyUtil(this, "getWindowIDs");
lazyUtil(this, "stringBundle");
lazyUtil(this, "updateModifiedScripts");
+lazyUtil(this, "windowEventTracker");
lazyUtil(this, "windowUnloader");
const {nsIContentPolicy: CP} = Ci;
@@ -112,6 +113,7 @@ ScriptishService.prototype = {
let unsafeWin = safeWin.wrappedJSObject;
let self = this;
let winClosed = false;
+ let tracker = Scriptish_windowEventTracker(safeWin);
// rechecks values that can change at any moment
function shouldNotRun() (
@@ -122,11 +124,22 @@ ScriptishService.prototype = {
// find matching scripts
Scriptish_config.initScripts(href, (safeWin === safeWin.top), function(scripts) {
+ let (windowLoaded = ("load" == tracker)) {
+ if (windowLoaded || "DOMContentLoaded" == tracker) {
+ scripts["document-start"] = scripts["document-start"].concat(scripts["document-end"], scripts["document-idle"]);
+ scripts["document-end"] = scripts["document-idle"] = [];
+ }
+
+ if (windowLoaded) {
+ scripts["document-start"] = scripts["document-start"].concat(scripts["window-load"]);
+ scripts["window-load"] = [];
+ }
+ }
+
if (scripts["document-end"].length || scripts["document-idle"].length) {
safeWin.addEventListener("DOMContentLoaded", function() {
if (shouldNotRun()) return;
- // inject @run-at document-idle scripts
if (scripts["document-idle"].length)
timeout(function() {
if (shouldNotRun()) return;
@@ -137,7 +150,6 @@ ScriptishService.prototype = {
});
});
- // inject @run-at document-end scripts
Scriptish_injectScripts({
scripts: scripts["document-end"],
url: href,
@@ -158,7 +170,6 @@ ScriptishService.prototype = {
}, true);
}
- // inject @run-at document-start scripts
Scriptish_injectScripts({
scripts: scripts["document-start"],
url: href,
@@ -1,5 +1,4 @@
(function(inc, tools, global){
-
inc("resource://scriptish/constants.js", tools);
const {lazyImport, lazyUtil} = tools;
lazyImport(global, "resource://scriptish/logging.js", ["Scriptish_log"]);
@@ -18,14 +17,13 @@ function updateExcludes({json}) {
}
var configJSON = sendSyncMessage("Scriptish:FrameSetup", "")[0];
+var scripts;
(function(configJSON) {
Scriptish_setExcludes(configJSON.excludes);
- var scripts = configJSON.scripts.map(function(i) {
- var script = SimpleScript.loadFromJSON(i);
- script.textContent = sendSyncMessage("Scriptish:GetScriptContents", script.id)[0];
- return script;
+ scripts = configJSON.scripts.map(function(i) {
+ return SimpleScript.loadFromJSON(i);
});
Scriptish_manager.setup({
@@ -36,6 +34,18 @@ var configJSON = sendSyncMessage("Scriptish:FrameSetup", "")[0];
})(configJSON);
addMessageListener("Scriptish:GlobalExcludesUpdate", updateExcludes);
+addMessageListener("Scriptish:ScriptInstalled", function({json}) {
+ scripts.push(SimpleScript.loadFromJSON(json));
+});
+addMessageListener("Scriptish:ScriptChanged", function({json}) {
+ var script = SimpleScript.loadFromJSON(json);
+ for (var i = scripts.length - 1; ~i; i--) {
+ if (scripts[i].id == script.id) {
+ scripts[i] = script;
+ return;
+ }
+ }
+});
})(Components.utils.import, {}, this);
@@ -8,6 +8,9 @@
lazyImport(this, "resource://scriptish/api/GM_Resources.js", ["GM_Resources"]);
lazyUtil(global, "installUri");
+ lazyUtil(global, "getScriptHeader");
+ lazyUtil(global, "notification");
+ lazyUtil(global, "openInTab");
var $ = function(id) document.getElementById(id);
@@ -16,18 +19,49 @@
inc("resource://scriptish/utils/Scriptish_updateChk.js");
var us_head = $("addons-userscripts");
- var next = us_head.nextSibling;
var parent = us_head.parentNode;
- Scriptish_config.scripts.forEach(function(script) {
+
+ function createNode(script) {
var ele = ExtensionsView._createItem(script, "userscript");
ele.setAttribute("typeLabel", "User Script");
// TODO: implement for Fennec.. #517
//ele.setAttribute("optionsURL", script.optionsURL);
ele.setAttribute("isDisabled", !script.enabled);
ele.setAttribute("data-scriptish-scriptid", script.id);
ele.addon = script;
- parent.insertBefore(ele, next);
- });
+ return ele;
+ }
+
+ function insertScript(script) {
+ parent.insertBefore(createNode(script), us_head.nextSibling);
+ }
+
+ // insert script nodes into the EM
+ Scriptish_config.scripts.forEach(insertScript);
+ Services.obs.addObserver({
+ observe: function(aSubject, aTopic, aData) {
+ tools.timeout(function() {
+ var script = Scriptish_config.getScriptById(JSON.parse(aData).id);
+ insertScript(script);
+ });
+ }
+ }, "scriptish-script-installed", false);
+
+ // replace script nodes when there is a change to script
+ var updateObs = {
+ observe: function(aSubject, aTopic, aData) {
+ tools.timeout(function() {
+ var script = Scriptish_config.getScriptById(JSON.parse(aData).id);
+ var node = createNode(script);
+ var id = node.getAttribute("id");
+ var oldNode = $(id);
+ if (oldNode) parent.replaceChild(node, oldNode);
+ else insertScript(script); // jic
+ });
+ }
+ };
+ Services.obs.addObserver(updateObs, "scriptish-script-modified", false);
+ Services.obs.addObserver(updateObs, "scriptish-script-updated", false);
}, false);
var mm = messageManager;
@@ -66,6 +100,19 @@
return rtnAry;
});
+ mm.addMessageListener("Scriptish:ScriptNotification", function({json}) {
+ Scriptish_notification.apply(null, json);
+ });
+
+ mm.addMessageListener("Scriptish:GetScriptMetadata", function({json}) {
+ return Scriptish_getScriptHeader(Scriptish_config.getScriptById(json.id), json.key, json.localVal);
+ });
+
+ mm.addMessageListener("Scriptish:OpenInTab", function({json}) {
+ json.push(global);
+ return Scriptish_openInTab.apply(null, json);
+ });
+
mm.loadFrameScript(
"chrome://scriptish/content/e10s/browser-content.js",
true); // no delay loading frame script
@@ -6,6 +6,8 @@ Components.utils.import("resource://scriptish/constants.js");
lazyImport(this, "resource://scriptish/config.js", ["Scriptish_config"]);
lazyImport(this, "resource://scriptish/utils/Scriptish_localizeDOM.js", ["Scriptish_localizeOnLoad"]);
+
+lazyUtil(this, "getScriptHeader");
lazyUtil(this, "stringBundle");
Scriptish_localizeOnLoad(this);
@@ -45,7 +47,7 @@ function delayedClose() timeout(close);
on("load", function() {
let script = scriptDownloader.script;
- let headers = script.getScriptHeader();
+ let headers = Scriptish_getScriptHeader(script);
// setup lists
["domains", "matches", "includes", "excludes"].forEach(function(i) {
@@ -1,7 +1,7 @@
-module("Script.header_parse");
+module("Scriptish_parser");
test("normal @keys (with space b4 @)", function() {
- var parser = importModule("resource://scriptish/script/script.js").Script.header_parse;
+ var parser = importModule("resource://scriptish/utils/Scriptish_parser.js").Scriptish_parser;
var header = (<><![CDATA[
// ==UserScript==
// @id test-id
@@ -22,7 +22,7 @@ test("normal @keys (with space b4 @)", function() {
});
test("normal @keys and following @fail", function() {
- var parser = importModule("resource://scriptish/script/script.js").Script.header_parse;
+ var parser = importModule("resource://scriptish/utils/Scriptish_parser.js").Scriptish_parser;
var header = (<><![CDATA[
// ==UserScript==
// @id test-id
@@ -41,7 +41,7 @@ test("normal @keys and following @fail", function() {
});
test("normal @keys and leading @fail", function() {
- var parser = importModule("resource://scriptish/script/script.js").Script.header_parse;
+ var parser = importModule("resource://scriptish/utils/Scriptish_parser.js").Scriptish_parser;
var header = (<><![CDATA[
// @fail test-fail
// ==UserScript==
@@ -60,7 +60,7 @@ test("normal @keys and leading @fail", function() {
});
test("two sets of normal @keys", function() {
- var parser = importModule("resource://scriptish/script/script.js").Script.header_parse;
+ var parser = importModule("resource://scriptish/utils/Scriptish_parser.js").Scriptish_parser;
var header = (<><![CDATA[
// ==UserScript==
// @id test-id
@@ -81,7 +81,7 @@ test("two sets of normal @keys", function() {
});
test("@keys without space b4 @", function() {
- var parser = importModule("resource://scriptish/script/script.js").Script.header_parse;
+ var parser = importModule("resource://scriptish/utils/Scriptish_parser.js").Scriptish_parser;
var header = (<><![CDATA[
//==UserScript==
//@id test-id
@@ -103,7 +103,7 @@ test("@keys without space b4 @", function() {
});
test("normal @keys case check", function() {
- var parser = importModule("resource://scriptish/script/script.js").Script.header_parse;
+ var parser = importModule("resource://scriptish/utils/Scriptish_parser.js").Scriptish_parser;
var header = (<><![CDATA[
// ==UserScript==
// @Key v1
@@ -23,13 +23,16 @@ error.hash.algorithm=Ungültiger Hash-Algorithmus angegeben.
error.icon.dataURL=Ungültige data:-URL für @icon
error.icon.notImage=Fehler! @icon hat keinen Bild MIME-Typ
error.icon.URL=Ungültige URL für @icon
+error.invalidCert=
error.isInvalidValue=ist ein ungültiger Wert
error.matchPattern.rules=@match Muster hält sich nicht an die Regeln für Muster
error.matchPattern.rules.file=File-Schema @match Muster hält sich nicht an die Regeln für Muster
+error.notSecure=
error.notSupported.Firefox=wird nicht in dieser Version von Firefox unterstützt
error.openingFile=Konnte Datei nicht öffnen
error.pattern.parsing=Muster konnte nicht verarbeitet werden
error.pref.type=Nicht unterstützter Einstellungstyp. Gültige Typen sind: string, bool und 32-bit int.
+error.remoteVersionOlder=
error.resource.dupName=ist ein doppelter Resourcenname. Jede @resource muss einen eindeutigen Namen tragen.
error.resource.syntax=Ungültige Syntax für @resource Deklaration
error.retrieving=Fehler beim Abrufen
@@ -23,13 +23,16 @@ error.hash.algorithm=Invalid hash algorithm specified.
error.icon.dataURL=Invalid data: URL for @icon
error.icon.notImage=Error! @icon does not have an image MIME type
error.icon.URL=Invalid URL for @icon
+error.invalidCert=Invalid SSL certificate.\nIf desired, allow all certificates by enabling the option in Scriptish Options / Advanced / Update Security.
error.isInvalidValue=is an invalid value
error.matchPattern.rules=@match pattern does not conform to pattern rules
error.matchPattern.rules.file=File scheme @match pattern does not conform to pattern rules
+error.notSecure=Insecure URI.\nIf desired, allow non-HTTPS updates by enabling the option in Scriptish Options / Advanced / Update Security.
error.notSupported.Firefox=is not supported by this version of Firefox
error.openingFile=Could not open file
error.pattern.parsing=Pattern could not be parsed
error.pref.type=Unsupported preference type. Valid types are: string, bool, and 32-bit integers.
+error.remoteVersionOlder=The remote script does not have a newer version number than your current script.
error.resource.dupName=is a duplicate resource name. Each @resource must have a unique name.
error.resource.syntax=Invalid syntax for @resource declaration
error.retrieving=Failed to retrieve
@@ -23,13 +23,16 @@ error.hash.algorithm=Especificado algoritmo de hash no válido.
error.icon.dataURL=URL de tipo datos para @ICON no válido
error.icon.notImage=¡Error!: @ICON no tiene un tipo MIME de imagen
error.icon.URL=URL para @ICON no válido
+error.invalidCert=
error.isInvalidValue=es un valor no permitido
error.matchPattern.rules=el filtro @match no se ajusta a las reglas para filtros
error.matchPattern.rules.file=El filtro @match del esquema File no se ajusta a las reglas para filtros
+error.notSecure=
error.notSupported.Firefox=no soportado por esta versión de Firefox
error.openingFile=Error abriendo el archivo
error.pattern.parsing=Error interpretando el filtro
error.pref.type=Tipo de preferencia no soportado. Tipos válidos: cadena, booleano y entero de 32 bits.
+error.remoteVersionOlder=
error.resource.dupName=es un nombre de recurso duplicado. Cada declaración @Resource debe tener un nombre único.
error.resource.syntax=Sintaxis no válida para la declaración @Resource
error.retrieving=Error al descargar
@@ -23,13 +23,16 @@ error.hash.algorithm=不正なハッシュ・アルゴリズムが指定され
error.icon.dataURL=不正なデータ: @icon 用 URL
error.icon.notImage=エラー! @icon が画像の MIME タイプではありません
error.icon.URL=@icon の URL が不正です
+error.invalidCert=
error.isInvalidValue=は不正な値です
error.matchPattern.rules=@match のパターンが記法に適合していません
error.matchPattern.rules.file=ファイル・スキーム(scheme)の @match パターンが記法に適合していません
+error.notSecure=
error.notSupported.Firefox=はこのバージョンの Firefox でサポートされていません
error.openingFile=ファイルを開くことが出来ませんでした
error.pattern.parsing=パターンを構文解析(parse)できませんでした
error.pref.type=サポートしてない設定の型です。正しい型は次の通り: string, bool, 32-bit integers
+error.remoteVersionOlder=
error.resource.dupName=はリソース名として重複しています。@resource の名前は一意でなければなりません
error.resource.syntax=@resource 宣言の構文が不正です
error.retrieving=取得に失敗しました
@@ -23,13 +23,16 @@ error.hash.algorithm=O algoritmo de hash especificado é inválido.
error.icon.dataURL=Dados inválidos: endereço para @icon
error.icon.notImage=Erro! @icon não tem um tipo MIME de imagem
error.icon.URL=Endereço inválido para @icon
+error.invalidCert=
error.isInvalidValue=é um nome inválido
error.matchPattern.rules=o padrão de @match não está de acordo com as regras.
error.matchPattern.rules.file=o padrão de @match do esquema "file:" não está de acordo com as regras.
+error.notSecure=
error.notSupported.Firefox=não é suportado por esta versão do Firefox
error.openingFile=Não foi possível abrir o arquivo
error.pattern.parsing=Não foi possível analisar o padrão
error.pref.type=Tipo de preferência não suportado. Os tipos válidos são: string, bool e integers de 32 bits.
+error.remoteVersionOlder=
error.resource.dupName=é um nome de recurso duplicado. Cada item de @resource precisa ter um nome exclusivo.
error.resource.syntax=sintaxe inválida para a declaração @resource.
error.retrieving=Falha ao obter
@@ -23,13 +23,16 @@ error.hash.algorithm=Неверный алгоритм хеширования.
error.icon.dataURL=Неверный URL для @icon
error.icon.notImage=
error.icon.URL=Неверный URL для @icon
+error.invalidCert=
error.isInvalidValue= - неверное значение
error.matchPattern.rules=шаблон @match не соответствует правилам
error.matchPattern.rules.file=Шаблон @match схемы file:// не соответствует правилам
+error.notSecure=
error.notSupported.Firefox=не поддерживается в этой версии Огненного Лиса
error.openingFile=Не могу открыть файл
error.pattern.parsing=Шаблон не парсится
error.pref.type=Неподдерживаемый тип настройки. Правильные типы: строка, булев и 32хбитное целое.
+error.remoteVersionOlder=
error.resource.dupName= - повторяющееся имя для ресурса. Имена ресурсов должны быть уникальными.
error.resource.syntax=Неправильный синтаксис в обьявлении @resource
error.retrieving=Failed to retrieve
@@ -23,13 +23,16 @@ error.hash.algorithm=Ogiltig hashalgoritm angavs.
error.icon.dataURL=Ogiltig data: URL för @icon
error.icon.notImage=Fel! @icon har ingen MIME-bildtyp
error.icon.URL=Ogiltig URL för @icon
+error.invalidCert=
error.isInvalidValue=är ett ogiltigt värde
error.matchPattern.rules=@match-mönster uppfyller inte mönsterreglerna
error.matchPattern.rules.file=@match-mönstret för filschema uppfyller inte mönsterreglerna
+error.notSecure=
error.notSupported.Firefox=stöds inte i denna version av Firefox
error.openingFile=Det gick inte att öppna filen
error.pattern.parsing=Det gick inte att parsa mönstret
error.pref.type=Inställningstypen stöds inte. Giltiga typer är: sträng, boolesk och 32-bitars heltal.
+error.remoteVersionOlder=
error.resource.dupName=är en resursnamnsdubblett. Varje @resource måste ha ett unikt namn.
error.resource.syntax=Ogiltig syntax för @resource-deklaration
error.retrieving=Det gick inte att hämta
Oops, something went wrong.

0 comments on commit 4d97c66

Please sign in to comment.