Skip to content

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 95 additions and 1 deletion.
  1. +3 −1 README.md
  2. +74 −0 bootstrap.js
  3. +18 −0 install.rdf
View
4 README.md
@@ -1,2 +1,4 @@
SaveAsFilename
-==============
+==============
+
+SuperStop is a Firefox addon that reverts the default Save As... filename to prefer the page filename rather than page title, to match the behavior of Firefox prior to version 18.
View
74 bootstrap.js
@@ -0,0 +1,74 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+var Cu = Components.utils;
+
+Cu.import("resource://gre/modules/Services.jsm");
+
+function startup(aData, aReason) {
+ // Monkeypatch all browser windows, current and future
+ watchWindows(function (window) {
+ });
+}
+
+function shutdown(aData, aReason) {
+ if (aReason != APP_SHUTDOWN) {
+ unloaders.forEach(function (f) {
+ try {
+ f();
+ } catch (ex) {}
+ });
+ }
+}
+
+function install(aData, aReason) { }
+
+function uninstall(aData, aReason) { }
+
+
+/* Code from: https://github.com/Mardak/restartless/blob/watchWindows/bootstrap.js */
+let unloaders = [];
+
+function watchWindows(callback) {
+ // Wrap the callback in a function that ignores failures
+ function watcher(window) {
+ try {
+ // Now that the window has loaded, only handle browser windows
+ let documentElement = window.document.documentElement;
+ if (documentElement.getAttribute("windowtype") == "navigator:browser")
+ callback(window);
+ }
+ catch(ex) {}
+ }
+
+ // Wait for the window to finish loading before running the callback
+ function runOnLoad(window) {
+ // Listen for one load event before checking the window type
+ window.addEventListener("load", function runOnce() {
+ window.removeEventListener("load", runOnce, false);
+ watcher(window);
+ }, false);
+ }
+
+ // Add functionality to existing windows
+ let windows = Services.wm.getEnumerator(null);
+ while (windows.hasMoreElements()) {
+ // Only run the watcher immediately if the window is completely loaded
+ let window = windows.getNext();
+ if (window.document.readyState == "complete")
+ watcher(window);
+ // Wait for the window to load before continuing
+ else
+ runOnLoad(window);
+ }
+
+ // Watch for new browser windows opening then wait for it to load
+ function windowWatcher(subject, topic) {
+ if (topic == "domwindowopened")
+ runOnLoad(subject);
+ }
+ Services.ww.registerNotification(windowWatcher);
+ unloaders.push(function() Services.ww.unregisterNotification(windowWatcher));
+}
+
View
18 install.rdf
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+ <Description about="urn:mozilla:install-manifest">
+ <em:id>saveasfilename@gavinsharp.com</em:id>
+ <em:type>2</em:type>
+ <em:name>SaveAsFilename</em:name>
+ <em:version>0.1</em:version>
+ <em:bootstrap>true</em:bootstrap>
+ <em:creator>Gavin Sharp</em:creator>
+ <em:targetApplication>
+ <Description>
+ <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
+ <em:minVersion>18.0</em:minVersion>
+ <em:maxVersion>21.*</em:maxVersion>
+ </Description>
+ </em:targetApplication>
+ </Description>
+</RDF>

No commit comments for this range

Something went wrong with that request. Please try again.