Permalink
Browse files

Closes #22 removing old Fennec code

  • Loading branch information...
1 parent f35c676 commit 94f0b4df82bf691225a0f618ba71afa1ca875e88 @erikvold erikvold committed Sep 23, 2012
@@ -1,20 +1,24 @@
+# TODO: remove/replace/improve
component {ca39e060-88ab-11df-a4ee-0800200c9a66} components/scriptish.js
contract @scriptish.erikvold.com/scriptish-service;1 {ca39e060-88ab-11df-a4ee-0800200c9a66}
category content-policy @scriptish.erikvold.com/scriptish-service;1 @scriptish.erikvold.com/scriptish-service;1
+# TODO: add this dynamically
component {5f28a810-8094-11e0-b278-0800200c9a66} components/aboutScriptish.js
contract @mozilla.org/network/protocol/about;1?what=scriptish {5f28a810-8094-11e0-b278-0800200c9a66}
+# TODO: REMOVE
content scriptish content/
+# TODO: register dynamically
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
style chrome://global/content/alerts/alert.xul chrome://scriptish/skin/third-party/alert.css os=Darwin
overlay chrome://browser/content/browser.xul chrome://scriptish/content/browser.xul application={ec8030f7-c20a-464f-9b0e-13a3a9e97384}
overlay chrome://browser/content/browser.xul chrome://scriptish/content/browser.xul application={92650c4d-4b8e-4d2a-b7eb-24ecf4f6b63a}
-overlay chrome://browser/content/browser.xul chrome://scriptish/content/e10s/browser.xul application={a23983c0-fd0e-11dc-95ff-0800200c9a66}
overlay chrome://browser/content/scratchpad.xul chrome://scriptish/content/scratchpad.xul
overlay chrome://navigator/content/navigator.xul chrome://scriptish/content/browser.xul
overlay about:addons chrome://scriptish/content/addonstab.xul
@@ -26,8 +30,7 @@ overlay chrome://scriptish/content/install.xul chrome://scriptish/content/clo
overlay chrome://scriptish/content/options.xul chrome://scriptish/content/closewindow.xul
overlay chrome://scriptish/content/newscript.xul chrome://scriptish/content/closewindow.xul
-override chrome://scriptish/content/options.xul chrome://scriptish/content/fennec-options.xul application={a23983c0-fd0e-11dc-95ff-0800200c9a66}
-
+# TODO: remove below, do dynamically.
locale scriptish en-US locale/en-US/
locale scriptish de locale/de/
locale scriptish es-ES locale/es-ES/
@@ -33,15 +33,11 @@ const RE_USERSCRIPT = /\.user(?:-\d+)?\.js$/;
const RE_CONTENTTYPE = /text\/html/i;
function ScriptishService() {
- if ("Fennec" != Services.appinfo.name) {
- Scriptish_manager.setup.call(this);
- Services.obs.addObserver(this, "install-userscript", false);
- Services.obs.addObserver(this, "scriptish-enabled", false);
- Services.obs.addObserver(this, "content-document-global-created", false);
- Services.obs.addObserver(this, "chrome-document-global-created", false);
- } else {
- //Services.mm.
- }
+ Scriptish_manager.setup.call(this);
+ Services.obs.addObserver(this, "install-userscript", false);
+ Services.obs.addObserver(this, "scriptish-enabled", false);
+ Services.obs.addObserver(this, "content-document-global-created", false);
+ Services.obs.addObserver(this, "chrome-document-global-created", false);
}
ScriptishService.prototype = {
@@ -1,67 +0,0 @@
-(function(inc, tools, global){
-inc("resource://scriptish/constants.js", tools);
-const {lazyImport, lazyUtil} = tools;
-lazyImport(global, "resource://scriptish/logging.js", ["Scriptish_log"]);
-lazyImport(global, "resource://scriptish/manager.js", ["Scriptish_manager"]);
-lazyImport(global, "resource://scriptish/script/simple-script.js", ["SimpleScript"]);
-lazyImport(global, "resource://scriptish/utils/Scriptish_isURLExcluded.js", [
- "Scriptish_setExcludes"
-]);
-
-global.Scriptish_installUri = function(aURL) {
- sendAsyncMessage("Scriptish:InstallScriptURL", aURL);
-}
-
-function updateExcludes({json}) {
- Scriptish_setExcludes(json);
-}
-
-var configJSON = sendSyncMessage("Scriptish:FrameSetup", "")[0];
-var scripts;
-
-(function(configJSON) {
- Scriptish_setExcludes(configJSON.excludes);
-
- scripts = configJSON.scripts.map(function(i) {
- return SimpleScript.loadFromJSON(i);
- });
-
- Scriptish_manager.setup({
- global: global,
- content: content,
- scripts: scripts
- });
-})(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;
- }
- }
-});
-addMessageListener("Scriptish:ScriptUninstalled", function({json}) {
- for (var i = scripts.length - 1; ~i; i--) {
- if (scripts[i].id == json) {
- scripts.splice(i, 1);
- return;
- }
- }
-});
-})(Components.utils.import, {}, this);
-
-
-addEventListener("load", function() {
- ContextHandler.registerType("userscript-install", function(popupState, element) {
- if (/\.user\.js$/.test(element.href)) {
- return true;
- }
- return false;
- });
-}, true);
@@ -1,126 +0,0 @@
-
-(function(inc, tools, global){
- inc("resource://scriptish/constants.js", tools);
- const {lazyImport, lazyUtil, Services} = tools;
- lazyImport(global, "resource://scriptish/logging.js", ["Scriptish_log"]);
- lazyImport(global, "resource://scriptish/manager.js", ["Scriptish_manager"]);
- lazyImport(global, "resource://scriptish/config.js", ["Scriptish_config"]);
- lazyImport(global, "resource://scriptish/api/GM_Resources.js", ["GM_Resources"]);
- lazyImport(global, "resource://scriptish/api/GM_ScriptStorage.js", ["GM_ScriptStorage"]);
-
- lazyUtil(global, "installUri");
- lazyUtil(global, "getScriptHeader");
- lazyUtil(global, "notification");
- lazyUtil(global, "openInTab");
-
- var $ = function(id) document.getElementById(id);
-
- addEventListener("load", function() {
- // Check if Scriptish has been updated/installed
- inc("resource://scriptish/utils/Scriptish_updateChk.js");
-
- var us_head = $("addons-userscripts");
- var parent = us_head.parentNode;
-
- 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;
- 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;
-
- mm.addMessageListener("Scriptish:InstallScriptURL", function({json}) {
- return Scriptish_installUri(json);
- });
-
- mm.addMessageListener("Scriptish:FrameSetup", function() {
- return Scriptish_config.toJSON();
- });
-
- mm.addMessageListener("Scriptish:GetScriptContents", function({json}) {
- return Scriptish_config.getScriptById(json).textContent;
- });
-
- mm.addMessageListener("Scriptish:GetScriptResourceURL", function({json}) {
- return new GM_Resources(Scriptish_config.getScriptById(json.scriptID)).getResourceURL(json.resource);
- });
-
- mm.addMessageListener("Scriptish:GetScriptResourceText", function({json}) {
- return new GM_Resources(Scriptish_config.getScriptById(json.scriptID)).getResourceText(json.resource);
- });
-
- mm.addMessageListener("Scriptish:GetScriptRequires", function({json}) {
- var script = Scriptish_config.getScriptById(json);
- if (!script) return [];
-
- var rtnAry = [];
- script.requires.forEach(function(req) {
- rtnAry.push({
- fileURL: req.fileURL,
- textContent: req.textContent
- });
- });
- return rtnAry;
- });
-
- mm.addMessageListener("Scriptish:ScriptNotification", function({json}) {
- Scriptish_notification.apply(null, json);
- });
-
- mm.addMessageListener("Scriptish:ScriptSetValue", function({json}) {
- var script = Scriptish_config.getScriptById(json.scriptID);
- var storage = new GM_ScriptStorage(script);
- return storage.setValue.apply(storage, json.args);
- });
-
- 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
-})(Components.utils.import, {}, this);
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?xml-stylesheet href="chrome://scriptish/skin/browser-fennec.css" type="text/css"?>
-<overlay id="scriptish-overlay" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <script type="application/javascript" src="chrome://scriptish/content/e10s/browser.js"/>
-
- <richlistbox id="context-commands">
- <richlistitem id="scriptish-userscript-install-context-command"
- class="context-command"
- type="userscript-install"
- onclick="Scriptish_installUri(ContextHelper.popupState.linkURL);">
- <label value="Install User Script"/>
- </richlistitem>
- </richlistbox>
-
- <richlistbox id="addons-list">
- <richlistitem id="addons-userscripts" insertbefore="addons-local" class="section-header" align="center">
- <label value="Your User Scripts" flex="1"/>
- </richlistitem>
- </richlistbox>
-</overlay>
@@ -1,8 +0,0 @@
-<?xml version="1.0"?>
-<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
- <setting pref="extensions.scriptish.enabled" type="bool" title="Scripts Enabled"/>
- <setting pref="extensions.scriptish.cache.enabled" type="bool" title="Cache Enabled"/>
- <setting pref="extensions.scriptish.uninstallPreferences" type="bool" title="Remove Script Preferences">
- Remove preferences associated with a user script when the script is uninstalled.
- </setting>
-</vbox>
@@ -17,21 +17,19 @@
(chromeWin.Browser ? chromeWin.Browser : chromeWin.gBrowser)
.addTab("about:scriptish");
- if ("Fennec" != tools.Services.appinfo.name) {
- // add toolbaritem to add-on bar
- var addToBar = chromeWin.document.getElementById("addon-bar");
- if (!addToBar || chromeWin.document.getElementById("scriptish-button"))
- return;
- var addonSet = (addToBar.getAttribute("currentset") || addToBar.getAttribute("defaultset")).split(",");
- var addonPos = addonSet.indexOf("status-bar");
- if (addonPos == -1) addonPos = addonSet.length;
- addonSet.splice(addonPos, 0, "scriptish-button");
- addonSet = addonSet.join(",");
- addToBar.setAttribute("currentset", addonSet);
- addToBar.currentSet = addonSet;
- chromeWin.BrowserToolboxCustomizeDone(true);
- chromeWin.document.persist(addToBar.getAttribute("id"), "currentset");
- if ("addon-bar" == addToBar.getAttribute("id")) addToBar.collapsed = false;
- }
+ // add toolbaritem to add-on bar
+ var addToBar = chromeWin.document.getElementById("addon-bar");
+ if (!addToBar || chromeWin.document.getElementById("scriptish-button"))
+ return;
+ var addonSet = (addToBar.getAttribute("currentset") || addToBar.getAttribute("defaultset")).split(",");
+ var addonPos = addonSet.indexOf("status-bar");
+ if (addonPos == -1) addonPos = addonSet.length;
+ addonSet.splice(addonPos, 0, "scriptish-button");
+ addonSet = addonSet.join(",");
+ addToBar.setAttribute("currentset", addonSet);
+ addToBar.currentSet = addonSet;
+ chromeWin.BrowserToolboxCustomizeDone(true);
+ chromeWin.document.persist(addToBar.getAttribute("id"), "currentset");
+ if ("addon-bar" == addToBar.getAttribute("id")) addToBar.collapsed = false;
}
})(Components.utils.import, {})
@@ -46,11 +46,6 @@ const Scriptish_ScriptProvider = {
Scriptish_notification(msg, null, null, callback);
}
- // notify content processes that there is a new script
- if ("Fennec" == Services.appinfo.name) {
- Scriptish_sendAsyncE10SMessage("Scriptish:ScriptInstalled", script.toJSON());
- }
-
break;
case "scriptish-script-edit-enabling":
AddonManagerPrivate.callAddonListeners(
@@ -59,12 +54,6 @@ const Scriptish_ScriptProvider = {
case "scriptish-script-edit-enabled":
AddonManagerPrivate.callAddonListeners(
aData.enabling ? "onEnabled" : "onDisabled", script);
-
- // notify content processes that a script's enabled state changed
- if ("Fennec" == Services.appinfo.name) {
- // TODO: use a more intelligent custom message handler
- Scriptish_sendAsyncE10SMessage("Scriptish:ScriptChanged", script.toJSON());
- }
break;
case "scriptish-script-modified":
case "scriptish-script-updated":
@@ -100,22 +89,12 @@ const Scriptish_ScriptProvider = {
Scriptish_notification(msg, null, null, callback);
}
- // notify content processes that a script has changed
- if ("Fennec" == Services.appinfo.name) {
- Scriptish_sendAsyncE10SMessage("Scriptish:ScriptChanged", script.toJSON());
- }
-
break;
case "scriptish-script-uninstalling":
AddonManagerPrivate.callAddonListeners("onUninstalling", script, false);
break;
case "scriptish-script-uninstalled":
AddonManagerPrivate.callAddonListeners("onUninstalled", script);
-
- // notify content processes that a script is uninstalled
- if ("Fennec" == Services.appinfo.name) {
- Scriptish_sendAsyncE10SMessage("Scriptish:ScriptUninstalled", script.id);
- }
break;
}
},
Oops, something went wrong.

0 comments on commit 94f0b4d

Please sign in to comment.