Reputation: 1
I have a simple page action that turns on when a specific url is recognized, modifies the url and updates the tab with the new url.
Below is my manifest.json
{
"name" : "SF Attachment",
"version" : "1.1",
"description" : "Open a SF attachment",
"background" :
{
"scripts": ["background.js"]
"persistent": false
},
"page_action" :
{
"default_icon" : "icon19.png",
"default_title" : "Open link"
},
"permissions": [ "tabs" ],
"icons" :
{
"19" : "icon19.png"
},
"manifest_version": 2
}
And my background.js:
function checkForValidURL(tabId, info, tab) {
var idx = tab.url.indexOf('file:///C:/Users/sk/Downloads');
if (idx > -1) {
chrome.pageAction.show(tabId);
chrome.pageAction.onClicked.addListener(function(tab)
{
chrome.tabs.create({url: "www.google.com"});
});
} else {
chrome.pageAction.hide(tabId);
}
}
chrome.tabs.onUpdated.addListener(checkForValidURL);
For now, I'm redirecting to google.com but the new url actually gets sent as
chrome-extension://najbfggahgkmlcifdoamdhgdllbkafeg/www.google.com
.
I read about web-accessible-resources and how this format of url is used by the extension for local files but that's not my situation and I don't believe I have that enabled anywhere, could that be the issue?
Upvotes: 0
Views: 257
Reputation: 115940
URLs in tabs.create
(and virtually any other URLs on the Web, e.g., window.open
or <a>
links) that do not begin with a scheme are treated as relative paths from the page currently running the script.
You must include a scheme, e.g. https://www.google.com
.
Upvotes: 4