← Commit history

fix nbrowser_back/forward: route through page history.back()/forward() (chrome.tabs.goBack threw 'no next page' on debugger-driven tabs even with valid history); ext 0.0.16

John Lauer ·746651e7be ·4mo ago ·parent 936e265
2 files changed +11−3
extension/manifest.json+1−1
@@ -2,7 +2,7 @@   "manifest_version": 3,   "name": "Adom for Chrome & Edge",   "short_name": "Adom",-  "version": "0.0.15",+  "version": "0.0.16",   "description": "Drive your real, logged-in Chrome/Edge from the Adom ecosystem \u2014 the native-browser counterpart to pup.",   "minimum_chrome_version": "116",   "background": {
extension/src/native.js+10−2
@@ -267,16 +267,24 @@ export async function reload(args = {}) {   return { ok: true, tabId: String(tabId), sessionId: args.sessionId }; } +// Route back/forward through the PAGE's own history, not chrome.tabs.goBack/goForward. The tabs API+// throws "Cannot find a next/previous page in history" on tabs whose navigations were driven by us+// (chrome.tabs.update + a lazily-attached debugger), even when window.history genuinely has entries.+// history.back()/forward() in the page context is reliable and stays banner-free (no debugger attach). export async function back(args = {}) {   const tabId = await resolveTabId(args);-  await chrome.tabs.goBack(tabId);+  const [{ result } = {}] = await chrome.scripting.executeScript({+    target: { tabId },+    func: () => { if (history.length <= 1) return 'no-history'; history.back(); return 'ok'; },+  });+  if (result === 'no-history') throw new Error('Cannot go back: no previous page in this tab history.');   await waitForLoad(tabId);   return { ok: true, tabId: String(tabId), sessionId: args.sessionId }; }  export async function forward(args = {}) {   const tabId = await resolveTabId(args);-  await chrome.tabs.goForward(tabId);+  await chrome.scripting.executeScript({ target: { tabId }, func: () => { history.forward(); } });   await waitForLoad(tabId);   return { ok: true, tabId: String(tabId), sessionId: args.sessionId }; }