From 8a659af44a8205f39e4c0e04146978447ca3f38e Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Fri, 24 Apr 2015 12:02:09 +0100 Subject: Get incognto state directly from chrome.extensions.inIncognitoContext --- background_scripts/main.coffee | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'background_scripts/main.coffee') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 31ada357..223b0d74 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -89,12 +89,11 @@ getCurrentTabUrl = (request, sender) -> sender.tab.url # Checks the user's preferences in local storage to determine if Vimium is enabled for the given URL, and # whether any keys should be passed through to the underlying page. # -root.isEnabledForUrl = isEnabledForUrl = (request, sender) -> +root.isEnabledForUrl = isEnabledForUrl = (request) -> rule = Exclusions.getRule(request.url) { isEnabledForUrl: not rule or rule.passKeys passKeys: rule?.passKeys or "" - incognito: sender.tab.incognito } # Retrieves the help dialog HTML template from a file, and populates it with the latest keybindings. -- cgit v1.2.3 From b3986dcd68a9383b3552ffb99c13c19e94bd08e4 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Fri, 24 Apr 2015 12:16:36 +0100 Subject: Re-check enabled state after history.pushState/location.hash is changed This uses the chrome.webRequest API to detect changes to page URL which *do not* cause the content script to refresh. --- background_scripts/main.coffee | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'background_scripts/main.coffee') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 223b0d74..ab92559f 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -96,6 +96,15 @@ root.isEnabledForUrl = isEnabledForUrl = (request) -> passKeys: rule?.passKeys or "" } +isEnabledForUpdatedUrl = (details) -> + message = isEnabledForUrl details + message.name = "updateEnabledForUrlState" + chrome.tabs.sendMessage details.tabId, message, {frameId: details.frameId} + +# Re-check whether Vimium is enabled for a frame when the url changes without a reload. +chrome.webNavigation.onHistoryStateUpdated.addListener isEnabledForUpdatedUrl # history.pushState. +chrome.webNavigation.onReferenceFragmentUpdated.addListener isEnabledForUpdatedUrl # Hash changed. + # Retrieves the help dialog HTML template from a file, and populates it with the latest keybindings. # This is called by options.coffee. root.helpDialogHtml = (showUnboundCommands, showCommandNames, customTitle) -> -- cgit v1.2.3 From 7b3b3b4b7e9b9b39cf583e857c4f384a4fff7fb1 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 25 Apr 2015 09:47:49 +0100 Subject: Remove requirement for Chrome 41. --- background_scripts/main.coffee | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'background_scripts/main.coffee') diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 6fac032c..f11b3b4a 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -96,14 +96,12 @@ root.isEnabledForUrl = isEnabledForUrl = (request) -> passKeys: rule?.passKeys or "" } -isEnabledForUpdatedUrl = (details) -> - message = isEnabledForUrl details - message.name = "updateEnabledForUrlState" - chrome.tabs.sendMessage details.tabId, message, {frameId: details.frameId} +onURLChange = (details) -> + chrome.tabs.sendMessage details.tabId, name: "checkEnabledAfterURLChange" # Re-check whether Vimium is enabled for a frame when the url changes without a reload. -chrome.webNavigation.onHistoryStateUpdated.addListener isEnabledForUpdatedUrl # history.pushState. -chrome.webNavigation.onReferenceFragmentUpdated.addListener isEnabledForUpdatedUrl # Hash changed. +chrome.webNavigation.onHistoryStateUpdated.addListener onURLChange # history.pushState. +chrome.webNavigation.onReferenceFragmentUpdated.addListener onURLChange # Hash changed. # Retrieves the help dialog HTML template from a file, and populates it with the latest keybindings. # This is called by options.coffee. -- cgit v1.2.3