Chrome Extension
Get last focused window.
chrome.windows.getLastFocused({
populate: true
},
(res) => {
console.log(res);
},
);
Get tab detail
chrome.tabs.get(699, (tab) => console.log(tab))
webRequest
http -> https
If you can’t visit http://www.google.com.hk
. It will atomically modify http
to https
.
chrome.webRequest.onErrorOccurred.addListener(
details => {
console.log(details);
if (details.type === 'main_frame' && /ERR_CONNECTION_TIMED_OUT|ERR_CONNECTION_RESET/.test(details.error) && /http:/.test(details.url)) {
chrome.tabs.update(details.tabId, {
url: details.url.replace('http:', 'https:'),
});
}
},
{
urls: ["<all_urls>"]
}
);
Comments
Leave a comment