-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(JS) update some scripts to take advantage of the
PanelMultiView enhancement in bug 1724622.
- Loading branch information
1 parent
a939a7e
commit d4f9899
Showing
4 changed files
with
969 additions
and
1,010 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,50 @@ | ||
// ==UserScript== | ||
// @name Backspace Panel Navigation | ||
// @version 1.1.0 | ||
// @version 1.1.1 | ||
// @author aminomancer | ||
// @homepage https://github.com/aminomancer | ||
// @description Press backspace to navigate back/forward in popup panels. | ||
// @license This Source Code Form is subject to the terms of the Creative Commons Attribution-NonCommercial-ShareAlike International License, v. 4.0. If a copy of the CC BY-NC-SA 4.0 was not distributed with this file, You can obtain one at http://creativecommons.org/licenses/by-nc-sa/4.0/ or send a letter to Creative Commons, PO Box 1866, Mountain View, CA 94042, USA. | ||
// ==/UserScript== | ||
|
||
(function () { | ||
function init() { | ||
const pc = Object.getPrototypeOf(PanelView.forNode(PanelUI.mainView)); | ||
eval( | ||
`pc.keyNavigation = function ` + | ||
pc.keyNavigation | ||
.toSource() | ||
.replace(/^\(/, "") | ||
.replace(/\)$/, "") | ||
.replace(/^keyNavigation\s*/, "") | ||
.replace(/^function\s*/, "") | ||
.replace( | ||
/(case \"ArrowLeft\"\:)/, | ||
`case "Backspace": | ||
function init() { | ||
const pc = Object.getPrototypeOf(PanelView.forNode(PanelUI.mainView)); | ||
eval( | ||
`pc.keyNavigation = function ` + | ||
pc.keyNavigation | ||
.toSource() | ||
.replace(/^\(/, "") | ||
.replace(/\)$/, "") | ||
.replace(/^keyNavigation\s*/, "") | ||
.replace(/^function\s*/, "") | ||
.replace( | ||
/(case \"ArrowLeft\"\:)/, | ||
`case "Backspace": | ||
if (tabOnly() || isContextMenuOpen()) { | ||
break; | ||
} | ||
stop(); | ||
if (PanelMultiView.forNode(this.node.panelMultiView).openViews.length > 1) { | ||
this.node.panelMultiView.goBack(); | ||
} else { | ||
PanelMultiView.forNode(this.node.panelMultiView)._panel.hidePopup(true); | ||
PanelMultiView.forNode(this.node.panelMultiView).hidePopup(true); | ||
} | ||
break; | ||
$1` | ||
) | ||
); | ||
} | ||
) | ||
); | ||
} | ||
|
||
if (gBrowserInit.delayedStartupFinished) { | ||
if (gBrowserInit.delayedStartupFinished) { | ||
init(); | ||
} else { | ||
let delayedListener = (subject, topic) => { | ||
if (topic == "browser-delayed-startup-finished" && subject == window) { | ||
Services.obs.removeObserver(delayedListener, topic); | ||
init(); | ||
} else { | ||
let delayedListener = (subject, topic) => { | ||
if (topic == "browser-delayed-startup-finished" && subject == window) { | ||
Services.obs.removeObserver(delayedListener, topic); | ||
init(); | ||
} | ||
}; | ||
Services.obs.addObserver(delayedListener, "browser-delayed-startup-finished"); | ||
} | ||
} | ||
}; | ||
Services.obs.addObserver(delayedListener, "browser-delayed-startup-finished"); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.