Compare commits

...
6 Commits
Author SHA1 Message Date
matmoul e16698ad39 Version 0.1.25 2026-11-16 22:54:33 +01:00
MatMoul 01cb753277 Merge pull request #195 from xan2622/fix-back-button
Fix Back button not returning to the parent folder
2026-11-16 22:50:55 +01:00
xan2622 f32a72210c Fix Back button not returning to the parent folder
The Back link used href="#" with an onclick calling history.back()
without preventing the default action: the fragment navigation was
applied before the asynchronous history traversal, which then only went
back to the same folder URL without '#'.

The Back link now targets the parent folder, so it also works when the
folder was opened in a new tab (no usable history). On a plain click,
when the previous history entry is the parent folder (checked with the
Navigation API when available), it goes back in history instead, so no
extra entry is added and the parent page state is restored. If the
traversal fails, the direct link is used. Modified clicks keep the
default link behavior.

Grid cells now reset their link target with removeAttribute('target'):
'delete link.target' is a no-op on an HTMLAnchorElement, so a cell that
had held a bookmark opened in a new tab kept target="_blank" after
paging, and a folder later shown there opened in a new tab despite the
'open folder' setting.

The dial URL building is shared by folder and Back links through
utils.getDialUrl, removing an unreachable branch (dial.path is never
empty).
2026-11-12 20:09:33 +01:00
MatMoul b1f76dadde Merge pull request #193 from manner82/fix/issue-192-context-menus-sendmessage
Fix context menus on dial page for Firefox 152+ (replace deprecated tabs.executeScript)
2026-06-28 15:34:52 +02:00
Robert Manner 7dc29e5a70 Version 0.1.24 2026-06-25 09:25:59 +02:00
Robert Manner 3fd4cd6d3b js: replace deprecated tabs.executeScript with tabs.sendMessage
The dial-page context menus invoked window.dial.* functions via
browser.tabs.executeScript. That API is deprecated since Firefox 149 and
removed in Firefox 152, which broke creating/editing bookmarks and folders
from the dial page (issue #192).

Switch the menu handlers to browser.tabs.sendMessage. New menu command IDs
(200-207) are added to the Commands enum in both background.js and dial.js,
and the existing runtime.onMessage listener in dial.js now dispatches these
commands to the corresponding dial.* functions using the page-side
_selectedItem state.

Fixes #192
2026-06-24 12:42:21 +02:00
3 changed files with 76 additions and 44 deletions

No files matched your search

+20 -34
View File
@@ -46,7 +46,15 @@ app.Messages.Commands = {
refreshNode: 9,
capturePage: 10,
settingsChanged: 100,
gridNodesLoaded: 101
gridNodesLoaded: 101,
menuCreateBookmark: 200,
menuCreateFolder: 201,
menuEditSettings: 202,
menuEditProperties: 203,
menuRefreshNode: 204,
menuCaptureHere: 205,
menuCapturePage: 206,
menuDeleteNode: 207
};
app.Messages.init = function(){ // Init Messages Listeners
browser.runtime.onMessage.addListener(function(request, sender, sendResponse){
@@ -302,18 +310,14 @@ app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context m
parentId: "pagemenunew",
title: browser.i18n.getMessage("menuNewBookmark"),
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.createBookmark();"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuCreateBookmark });
}
});
browser.contextMenus.create({
parentId: "pagemenunew",
title: browser.i18n.getMessage("menuNewFolder"),
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.createFolder();"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuCreateFolder });
}
});
browser.contextMenus.create({ parentId: "pagemenu", type: "separator" });
@@ -321,9 +325,7 @@ app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context m
parentId: "pagemenu",
title: browser.i18n.getMessage("menuSettings"),
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.editSettings();"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuEditSettings });
}
});
// Create WebExt Link Context menu
@@ -342,18 +344,14 @@ app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context m
parentId: "itemmenunew",
title: browser.i18n.getMessage("menuNewBookmark"),
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.createBookmark();"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuCreateBookmark });
}
});
browser.contextMenus.create({
parentId: "itemmenunew",
title: browser.i18n.getMessage("menuNewFolder"),
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.createFolder();"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuCreateFolder });
}
});
browser.contextMenus.create({ parentId: "itemmenu", type: "separator" });
@@ -361,18 +359,14 @@ app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context m
parentId: "itemmenu",
title: browser.i18n.getMessage("menuProperties"),
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.editProperties(window.dial._selectedItem);"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuEditProperties });
}
});
browser.contextMenus.create({
parentId: "itemmenu",
title: browser.i18n.getMessage("menuRefreshItem"),
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.refreshNode(window.dial._selectedItem);"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuRefreshNode });
}
});
browser.contextMenus.create({
@@ -380,27 +374,21 @@ app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context m
title: browser.i18n.getMessage("menuCaptureHere"),
visible: false,
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.captureHere(window.dial._selectedItem);"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuCaptureHere });
}
});
browser.contextMenus.create({
parentId: "itemmenu",
title: browser.i18n.getMessage("menuCapturePage"),
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.capturePage(window.dial._selectedItem);"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuCapturePage });
}
});
browser.contextMenus.create({
parentId: "itemmenu",
title: browser.i18n.getMessage("menuDeleteItem"),
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.deleteNode();"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuDeleteNode });
}
});
browser.contextMenus.create({ parentId: "itemmenu", type: "separator" });
@@ -408,9 +396,7 @@ app.ContextMenus.initMenu = function(){ // (Called from app.init) Init context m
parentId: "itemmenu",
title: browser.i18n.getMessage("menuSettings"),
onclick(info, tab) {
browser.tabs.executeScript(tab.id, {
code: "window.dial.editSettings();"
});
browser.tabs.sendMessage(tab.id, { cmd: app.Messages.Commands.menuEditSettings });
}
});
};
+55 -9
View File
@@ -60,6 +60,11 @@ utils.getPath = function(){
if(path) return path + '/';
else return '/';
};
utils.getDialUrl = function(path){
var url = '?bg=' + encodeURIComponent(app.settings.backgroundColor);
if(path) url += '&path=' + encodeURIComponent(path);
return url;
};
app.init = function(){
app.Messages.getSettings(function(settings){
@@ -84,7 +89,15 @@ app.Messages.Commands = {
refreshNode: 9,
capturePage: 10,
settingsChanged: 100,
gridNodesLoaded: 101
gridNodesLoaded: 101,
menuCreateBookmark: 200,
menuCreateFolder: 201,
menuEditSettings: 202,
menuEditProperties: 203,
menuRefreshNode: 204,
menuCaptureHere: 205,
menuCapturePage: 206,
menuDeleteNode: 207
};
app.Messages.init = function(){
browser.runtime.onMessage.addListener(function(request, sender, sendResponse){
@@ -95,6 +108,30 @@ app.Messages.init = function(){
case app.Messages.Commands.gridNodesLoaded:
if(dial.skipUpdate!=true) app.Messages.getNode(dial.path, app.GridNodes._changed);
break;
case app.Messages.Commands.menuCreateBookmark:
dial.createBookmark();
break;
case app.Messages.Commands.menuCreateFolder:
dial.createFolder();
break;
case app.Messages.Commands.menuEditSettings:
dial.editSettings();
break;
case app.Messages.Commands.menuEditProperties:
dial.editProperties(dial._selectedItem);
break;
case app.Messages.Commands.menuRefreshNode:
dial.refreshNode(dial._selectedItem);
break;
case app.Messages.Commands.menuCaptureHere:
dial.captureHere(dial._selectedItem);
break;
case app.Messages.Commands.menuCapturePage:
dial.capturePage(dial._selectedItem);
break;
case app.Messages.Commands.menuDeleteNode:
dial.deleteNode();
break;
}
});
};
@@ -485,7 +522,7 @@ dial.populateGrid = function(){
link.Node = null;
link.className = 'Empty';
link.childNodes[0].style.backgroundImage = '';
if(link.target) delete link.target;
link.removeAttribute('target');
link.href = null;
link.onclick = null;
link.removeAttribute('contextmenu');
@@ -495,9 +532,19 @@ dial.populateGrid = function(){
link.className = 'Back';
link.childNodes[0].style.backgroundImage = '';
link.childNodes[1].innerText = 'Back';
if(link.target) delete link.target;
link.href = '#';
link.onclick = function(){ window.history.back(); }
link.removeAttribute('target');
var parentPath = dial.path.substring(0, dial.path.lastIndexOf('/', dial.path.length - 2));
link.href = utils.getDialUrl(parentPath);
link.onclick = function(e){
if(e.ctrlKey || e.shiftKey || e.altKey || e.metaKey) return;
if(!window.navigation || !navigation.canGoBack) return;
var previousUrl = navigation.entries()[navigation.currentEntry.index - 1].url;
if(!previousUrl) return;
previousUrl = new URL(previousUrl);
if(previousUrl.pathname != location.pathname || (previousUrl.searchParams.get('path') || '') != parentPath) return;
e.preventDefault();
navigation.back().committed.catch(function(){ location.assign(link.href); });
};
link.removeAttribute('contextmenu');
}
populateFolder = function(link, node){
@@ -512,14 +559,13 @@ dial.populateGrid = function(){
link.childNodes[1].innerText = node.title;
switch(app.settings.grid.openFolderMethod){
case 0:
if(link.target) delete link.target;
link.removeAttribute('target');
break;
case 1:
link.target = '_blank';
break;
}
if(dial.path) link.href = '?' + 'bg=' + encodeURIComponent(app.settings.backgroundColor) + '&path=' + encodeURIComponent(dial.path + node.title);
else link.href = '?' + 'bg=' + encodeURIComponent(app.settings.backgroundColor) + '&path=' + encodeURIComponent(node.title);
link.href = utils.getDialUrl(dial.path + node.title);
link.onclick = null;
link.setAttribute('contextmenu', 'item');
}
@@ -539,7 +585,7 @@ dial.populateGrid = function(){
link.childNodes[1].innerText = node.title;
switch(app.settings.grid.openBookmarkMethod){
case 0:
if(link.target) delete link.target;
link.removeAttribute('target');
break;
case 1:
link.target = '_blank';
+1 -1
View File
@@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Quick Dial",
"version": "0.1.23",
"version": "0.1.25",
"author": "MatMoul",
"homepage_url": "https://github.com/MatMoul/quickdial-webext",
"developer": {