Skip to content

Commit

Permalink
fix: reload tab if osm, else reload maps frames only
Browse files Browse the repository at this point in the history
  • Loading branch information
nobkd committed Apr 18, 2023
1 parent 6d9cebe commit 06b88ba
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/bg/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ browserAction.onClicked.addListener(async (tab: Tabs.Tab) => {
updateIcon(hostname);

let frames = (await webNavigation.getAllFrames({ tabId: tab.id })) ?? [];
frames = frames.filter((frame) => {
return frame.url.match(matcher) || frame.url.match(replacedUrlMatcher);
});

// matches osm frames (just reloading the frame ist not working for some reason, so in case of replaced maps the whole tab is reloaded)
if (frames.some((frame) => frame.url.match(replacedUrlMatcher))) {
tabs.reload(tab.id, { bypassCache: true });
return;
}

// matches maps frames (finds the frames that have maps and reloads only them)
frames = frames.filter((frame) => frame.url.match(matcher));
frames.forEach((frame) => {
// TODO: currently only works "from maps to osm" and "not from osm to maps" => fix it...
tabs.executeScript(tab.id, {
frameId: frame.frameId,
code: 'document.location.reload();',
Expand Down

0 comments on commit 06b88ba

Please sign in to comment.