Permalink
Browse files

Global excludes.

* Restore/reformat some old strings. (Source: partial revert of ed58935 and b42a197.)
* Define a 'clude editor; reusable via XBL binding.
* Insert it into the options dialog.
* Add globalExcludes to Config.
* Read them at Script.matchesURL() time.

Fixes #1002
  • Loading branch information...
1 parent 80c62e8 commit 728a048ab526fa6620d38f5b45066b4a98084185 @arantius arantius committed Jul 25, 2011
View
@@ -0,0 +1,97 @@
+<?xml version="1.0"?>
+<!DOCTYPE overlay SYSTEM "chrome://greasemonkey/locale/gm-cludes.dtd">
+<bindings xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+ <binding id="clude-editor">
+ <content>
+ <xul:hbox flex="1">
+ <xul:listbox flex="1" id="listbox" />
+ <xul:vbox>
+ <xul:button id="btnAdd" label="&button.add;" oncommand="_onAddPage()" />
+ <xul:button id="btnEdit" label="&button.edit;" oncommand="_onEditPage()"
+ disabled="true" />
+ <xul:button id="btnDel" label="&button.remove;" oncommand="_onRemovePage()"
+ disabled="true" />
+ <xul:spacer flex="1" />
+ </xul:vbox>
+ </xul:hbox>
+ </content>
+ <implementation>
+ <constructor>
+ this._box = document.getAnonymousElementByAttribute(
+ this, 'id', 'listbox');
+ this._btnAdd = document.getAnonymousElementByAttribute(
+ this, 'id', 'btnAdd');
+ this._btnEdit = document.getAnonymousElementByAttribute(
+ this, 'id', 'btnEdit');
+ this._btnDel = document.getAnonymousElementByAttribute(
+ this, 'id', 'btnDel');
+
+ this._pages = [];
+ this._fillListbox();
+ </constructor>
+
+ <property name="pages">
+ <getter>
+ return this._pages.concat();
+ </getter>
+ <setter>
+ this._pages = val.concat();
+ this._fillListbox();
+ return null;
+ </setter>
+ </property>
+
+ <method name="_fillListbox">
+ <parameter name="pages" />
+ <body>
+ pages = pages || this._pages;
+ while (this._box.getRowCount()) this._box.removeItemAt(0);
+ for (var i = 0, page = null; page = pages[i]; i++) {
+ this._box.insertItemAt(this._box.getRowCount(), page);
+ }
+ </body>
+ </method>
+
+ <method name="_onAddPage">
+ <body>
+ var page = prompt(
+ "&promptForNewPage.msg;",
+ "&promptForNewPage.defVal;",
+ "&promptForNewPage.title;");
+ if (page) this._pages.push(page);
+ this._fillListbox();
+ </body>
+ </method>
+
+ <method name="_onEditPage">
+ <body>
+ var page = prompt(
+ "&promptForEdit.msg;",
+ this._pages[this._box.currentIndex],
+ "&promptForEdit.title;");
+ if (page) this._pages[this._box.currentIndex] = page;
+ this._fillListbox();
+ </body>
+ </method>
+
+ <method name="_onRemovePage">
+ <body>
+ this._pages.splice(this._box.currentIndex, 1);
+ this._fillListbox();
+ </body>
+ </method>
+
+ <method name="_onSelect">
+ <body>
+ var noSelection = this._box.currentIndex == -1;
+ this._btnEdit.disabled = noSelection;
+ this._btnDel.disabled = noSelection;
+ </body>
+ </method>
+ </implementation>
+ <handlers>
+ <handler event="select" action="this._onSelect();"/>
+ </handlers>
+ </binding>
+</bindings>
View
@@ -7,6 +7,8 @@ function Config() {
this._configFile.append("config.xml");
this._initScriptDir();
+ this._globalExcludes = JSON.parse(GM_prefRoot.getValue("globalExcludes"));
+
this._observers = [];
}
@@ -365,9 +367,20 @@ Config.prototype._initScriptDir = function() {
}
};
+Config.prototype.__defineGetter__('globalExcludes',
+function Config_getGlobalExcludes() { return this._globalExcludes.concat(); }
+);
+
+Config.prototype.__defineSetter__('globalExcludes',
+function Config_setGlobalExcludes(val) {
+ this._globalExcludes = val.concat();
+ GM_prefRoot.setValue("globalExcludes", JSON.stringify(this._globalExcludes));
+});
+
Config.prototype.__defineGetter__('scripts',
function Config_getScripts() { return this._scripts.concat(); }
);
+
Config.prototype.getMatchingScripts = function(testFunc) {
return this._scripts.filter(testFunc);
};
View
@@ -1,9 +1,13 @@
-function GM_onloadOptions() {
+function GM_loadOptions() {
document.getElementById("check-uninstall")
.checked = GM_prefRoot.getValue("uninstallPreferences");
+ document.getElementById("globalExcludes")
+ .pages = GM_getConfig().globalExcludes;
}
-function GM_setUninstallPrefs(checkbox) {
+function GM_saveOptions(checkbox) {
GM_prefRoot.setValue("uninstallPreferences",
!!document.getElementById("check-uninstall").checked);
+ GM_getConfig().globalExcludes =
+ document.getElementById("globalExcludes").pages;
}
View
@@ -8,14 +8,17 @@
]>
<?xml-stylesheet href="chrome://global/skin/global.css" type="text/css"?>
+<?xml-stylesheet href="chrome://greasemonkey/skin/bindings.css" type="text/css"?>
+<?xml-stylesheet href="chrome://greasemonkey/skin/options.css" type="text/css"?>
<dialog
title="Greasemonkey - &prefWindow.titleWin;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons="accept"
id="greasemonkey-options-dialog"
persist="screenX screenY"
- onload="GM_onloadOptions()"
+ onload="GM_loadOptions()"
+ ondialogaccept="GM_saveOptions()"
>
<script type="application/x-javascript" src="chrome://greasemonkey/content/prefmanager.js" />
<script type="application/x-javascript" src="chrome://greasemonkey/content/utils.js" />
@@ -26,14 +29,17 @@
<vbox>
<groupbox>
<caption label="&options.editor;" />
- <button oncommand="GM_getEditor(true)"><label>&options.changeEditor;</label></button>
+ <button oncommand="GM_getEditor(true)" label="&options.changeEditor;" />
</groupbox>
<groupbox>
<caption label="&Uninstall;" />
- <checkbox id="check-uninstall"
- label="&AlsoUninstallPrefs;"
- oncommand="GM_setUninstallPrefs(this)" />
+ <checkbox id="check-uninstall" label="&AlsoUninstallPrefs;" />
+ </groupbox>
+
+ <groupbox>
+ <caption label="&options.globalExcludes;" />
+ <cludes id="globalExcludes" />
</groupbox>
</vbox>
View
@@ -50,8 +50,9 @@ Script.prototype.matchesURL = function(url) {
}
return GM_isGreasemonkeyable(url)
- && (this._includes.some(testClude) || this._matches.some(testMatch))
- && !this._excludes.some(testClude);
+ && !GM_getConfig()._globalExcludes.some(testClude)
+ && !this._excludes.some(testClude)
+ && (this._includes.some(testClude) || this._matches.some(testMatch));
};
Script.prototype._changed = function(event, data) {
@@ -1,5 +1,6 @@
pref("extensions.{e4a8a97b-f2ed-450b-b12d-ee082ba24781}.description", "chrome://greasemonkey/locale/greasemonkey.properties");
pref("greasemonkey.fileIsGreaseable", false);
+pref("greasemonkey.globalExcludes", '[]');
pref("greasemonkey.unmhtIsGreaseable", false);
pref("greasemonkey.enableScriptRefreshing", true);
pref("greasemonkey.uninstallPreferences", true);
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Entra una nova URL. Pots especificar múltiples pàgines utilitzant el caràcter comodí (*)">
+<!ENTITY promptForNewPage.title "Afegeix pàgina">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Modifica la URL de la pàgina de sota. Pots especificar múltiples pàgines utilitzant el caràcter comodí (*)">
+<!ENTITY promptForEdit.title "Edita pàgina">
+<!ENTITY button.add "Afegeix...">
+<!ENTITY button.edit "Edita...">
+<!ENTITY button.remove "Elimina">
+<!ENTITY label.grpIncluded "Pàgines incloses">
+<!ENTITY label.grpExcluded "Pàgines excloses">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Sem napište novou adresu. Můžete blíže určit několik adres pomocí divokých znaků (*).">
+<!ENTITY promptForNewPage.title "Přidat stránku">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Zde upravte stávající adresu. Můžete blíže určit několik adres pomocí divokých znaků (*).">
+<!ENTITY promptForEdit.title "Upravit stránku">
+<!ENTITY button.add "Přidat...">
+<!ENTITY button.edit "Upravit...">
+<!ENTITY button.remove "Odstranit">
+<!ENTITY label.grpIncluded "Zahrnout stránky">
+<!ENTITY label.grpExcluded "Vyjmout stránky">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Geben Sie unten eine neue URL ein. Sie können Platzhalter (*) verwenden, um mehrere Seiten gleichzeitig festzulegen.">
+<!ENTITY promptForNewPage.title "Seite hinzufügen">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Passen Sie die URL der Seite an. Sie können Platzhalter (*) verwenden, um mehrere Seiten gleichzeitig festzulegen.">
+<!ENTITY promptForEdit.title "Seite bearbeiten">
+<!ENTITY button.add "Hinzufügen...">
+<!ENTITY button.edit "Bearbeiten...">
+<!ENTITY button.remove "Entfernen">
+<!ENTITY label.grpIncluded "Auf diese Seiten anwenden:">
+<!ENTITY label.grpExcluded "Nicht auf diese Seiten anwenden:">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Enter a new URL below. You can specify multiple pages using the wildcard (*) character.">
+<!ENTITY promptForNewPage.title "Add Page">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Modify the URL of the page below. You can specify multiple pages using the wildcard (*) character.">
+<!ENTITY promptForEdit.title "Edit Page">
+<!ENTITY button.add "Add...">
+<!ENTITY button.edit "Edit...">
+<!ENTITY button.remove "Remove">
+<!ENTITY label.grpIncluded "Included Pages">
+<!ENTITY label.grpExcluded "Excluded Pages">
@@ -25,6 +25,7 @@
<!ENTITY newscript.excludes "Excludes (One per line)">
<!ENTITY options.editor "Editor">
<!ENTITY options.changeEditor "Change Editor">
+<!ENTITY options.globalExcludes "Global Excludes">
<!ENTITY userscripts "User Scripts">
<!ENTITY Uninstall "Uninstall">
<!ENTITY AlsoUninstallPrefs "Also uninstall associated preferences">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Introduce abajo una nueva dirección. Puedes indicar varias páginas web usando el asterisco (*).">
+<!ENTITY promptForNewPage.title "Añadir página web.">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Modificar la dirección de la pagina de abajo. Puedes indicar varias páginas web usando el asterisco (*).">
+<!ENTITY promptForEdit.title "Editar página.">
+<!ENTITY button.add "Añadir...">
+<!ENTITY button.edit "Editar...">
+<!ENTITY button.remove "Borrar">
+<!ENTITY label.grpIncluded "Páginas incluidas">
+<!ENTITY label.grpExcluded "Páginas excluidas">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "یک نشانی جدید در زیر وارد کنید. شما می توانید صفحات متعددی را با استفاده از علامت عام (*) معین کنید.">
+<!ENTITY promptForNewPage.title "اضافه کردن صفحه">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "نشانی صفحه را در زیر تغییر دهید. شما می توانید صفحات متعددی را با استفاده از علامت عام (*) معین کنید.">
+<!ENTITY promptForEdit.title "ویرایش صفحه">
+<!ENTITY button.add "اضافه کردن...">
+<!ENTITY button.edit "ویرایش...">
+<!ENTITY button.remove "پاک کردن">
+<!ENTITY label.grpIncluded "صفحه های شامل شده">
+<!ENTITY label.grpExcluded "صفحه های مستثنى شده">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Anna uusi URL-linkki. Voit myös käyttää tähti-merkkiä (*).">
+<!ENTITY promptForNewPage.title "Lisää sivu">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Muokkaa sivun URL-linkkiä. Voit myös käyttää tähti-merkkiä (*).">
+<!ENTITY promptForEdit.title "Muokkaa sivua">
+<!ENTITY button.add "Lisää...">
+<!ENTITY button.edit "Muokkaa...">
+<!ENTITY button.remove "Poista">
+<!ENTITY label.grpIncluded "Käytä sivuilla">
+<!ENTITY label.grpExcluded "Pois lukien sivut">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Entrez une nouvelle URL ci-dessous. Il est possible de préciser un ensemble de pages en utilisant l'astérisque (*) comme joker.">
+<!ENTITY promptForNewPage.title "Ajouter la page">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Modifiez l'URL de la page ci-dessous. Il est possible de préciser un ensemble de pages en utilisant l'astérisque (*) comme joker.">
+<!ENTITY promptForEdit.title "Éditer la page">
+<!ENTITY button.add "Ajouter…">
+<!ENTITY button.edit "Éditer…">
+<!ENTITY button.remove "Supprimer">
+<!ENTITY label.grpIncluded "Pages autorisées">
+<!ENTITY label.grpExcluded "Pages interdites">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Introduza unha nova URL embaixo. Podes indicar múltiplas páxinas empregando o asterisco (*).">
+<!ENTITY promptForNewPage.title "Engadir Páxina">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Modificar a URL da páxina embaixo. Podes indicar múltiplas páxinas empregando o asterisco (*).">
+<!ENTITY promptForEdit.title "Editar Páxina">
+<!ENTITY button.add "Engadir...">
+<!ENTITY button.edit "Editar...">
+<!ENTITY button.remove "Eliminar">
+<!ENTITY label.grpIncluded "Páxinas Incluídas">
+<!ENTITY label.grpExcluded "Páxinas Excluídas">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "הכנס כתובת אינטרנט חדשה. ניתן לציין דפים מרובים ע"י שימוש בתו *.">
+<!ENTITY promptForNewPage.title "הוסף דף">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "שנה את כתובת הדף. ניתן לציין דפים מרובים ע"י שימוש בתו *.">
+<!ENTITY promptForEdit.title "ערוך דף">
+<!ENTITY button.add "הוסף...">
+<!ENTITY button.edit "ערוך...">
+<!ENTITY button.remove "הסר">
+<!ENTITY label.grpIncluded "כלול דפים">
+<!ENTITY label.grpExcluded "אל תכלול דפים">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Inserire un nuovo URL di seguito. È possibile specificare più pagine utilizzando il carattere jolly (*).">
+<!ENTITY promptForNewPage.title "Aggiungi pagina">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Modificare l'URL della pagina di seguito. È possibile specificare più pagine utilizzando il carattere jolly (*).">
+<!ENTITY promptForEdit.title "Modifica pagina">
+<!ENTITY button.add "Aggiungi...">
+<!ENTITY button.edit "Modifica...">
+<!ENTITY button.remove "Rimuovi">
+<!ENTITY label.grpIncluded "Pagine incluse">
+<!ENTITY label.grpExcluded "Pagine escluse">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "以下にURLを入力してください。複数のページを指定する場合、ワイルドカード (*) が使用できます。">
+<!ENTITY promptForNewPage.title "ページの追加">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "以下のURLを修正してください。複数のページを指定する場合、ワイルドカード (*) が使用できます。">
+<!ENTITY promptForEdit.title "ページの編集">
+<!ENTITY button.add "追加...">
+<!ENTITY button.edit "編集...">
+<!ENTITY button.remove "削除">
+<!ENTITY label.grpIncluded "ユーザスクリプトを実行するページ">
+<!ENTITY label.grpExcluded "ユーザスクリプトを実行しないページ">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "새로운 URL을 아래에 입력하세요. 와일드카드(*)를 사용하여 여러 페이지를 지정할 수도 있습니다.">
+<!ENTITY promptForNewPage.title "페이지 추가">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "아래의 URL을 수정하세요. 와일드카드(*)를 사용하여 여러 페이지를 지정할 수도 있습니다.">
+<!ENTITY promptForEdit.title "페이지 수정">
+<!ENTITY button.add "추가...">
+<!ENTITY button.edit "수정...">
+<!ENTITY button.remove "삭제">
+<!ENTITY label.grpIncluded "동작할 페이지">
+<!ENTITY label.grpExcluded "동작하지 않을 페이지">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Voer hieronder een nieuwe URL in. U kunt meerdere pagina’s specificeren m.b.v. een ‘wildcard’ (*).">
+<!ENTITY promptForNewPage.title "Pagina toevoegen">
+<!ENTITY promptForNewPage.defVal "http://www.URL.nl/*">
+<!ENTITY promptForEdit.msg "Verander de URL van onderstaande pagina. U kunt meerderr pagina’s specificeren m.b.v. een ‘wildcard’ (*).">
+<!ENTITY promptForEdit.title "Pagina bewerken">
+<!ENTITY button.add "Toevoegen…">
+<!ENTITY button.edit "Bewerken…">
+<!ENTITY button.remove "Verwijderen">
+<!ENTITY label.grpIncluded "Inclusief deze pagina’s">
+<!ENTITY label.grpExcluded "Exclusief deze pagina’s">
View
@@ -0,0 +1,5 @@
+<!ENTITY button.add "Dodaj">
+<!ENTITY button.edit "Edytuj">
+<!ENTITY button.remove "Usuń">
+<!ENTITY label.grpIncluded "Witryny, na których skrypt jest uruchamiany">
+<!ENTITY label.grpExcluded "Witryny, na których skrypt nie jest uruchamiany">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Digite uma nova URL abaixo. Você pode abranger várias, usando o caractere (*) coringa.">
+<!ENTITY promptForNewPage.title "Adicionar Página">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Altere a URL da página abaixo. Você pode abranger várias, usando o caractere (*) coringa.">
+<!ENTITY promptForEdit.title "Editar Página">
+<!ENTITY button.add "Adicionar...">
+<!ENTITY button.edit "Editar...">
+<!ENTITY button.remove "Remover">
+<!ENTITY label.grpIncluded "Páginas Incluídas">
+<!ENTITY label.grpExcluded "Páginas Excluídas">
View
@@ -0,0 +1,10 @@
+<!ENTITY promptForNewPage.msg "Введите адрес нового URL-адреса ниже. Вы можете установить своё множество страниц, используя символ звёздочки (*).">
+<!ENTITY promptForNewPage.title "Добавить адрес страницы">
+<!ENTITY promptForNewPage.defVal "http://example.com/*">
+<!ENTITY promptForEdit.msg "Измените URL страницы ниже. Вы можете установить своё множество страниц, используя символ звёздочки (*).">
+<!ENTITY promptForEdit.title "Редактирование адреса страницы">
+<!ENTITY button.add "Добавить...">
+<!ENTITY button.edit "Изменить...">
+<!ENTITY button.remove "Удалить">
+<!ENTITY label.grpIncluded "Охватываемые адреса">
+<!ENTITY label.grpExcluded "Исключаемые адреса">
Oops, something went wrong.

0 comments on commit 728a048

Please sign in to comment.