Skip to content

Commit

Permalink
优化体验,不需要等待 404 了
Browse files Browse the repository at this point in the history
  • Loading branch information
EkkoG committed Sep 4, 2020
1 parent 71b0453 commit 4d5ab16
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions background.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Array.prototype.insert = function ( index, item ) {
this.splice( index, 0, item );
};
chrome.webNavigation.onErrorOccurred.addListener(function(details)
chrome.webNavigation.onBeforeNavigate.addListener(function(details)
{
if (details.frameId != 0) //ignore subframes. 0 is main frame
{ return; }
Expand All @@ -11,14 +11,14 @@ chrome.webNavigation.onErrorOccurred.addListener(function(details)
if (url_arr[3] === 'app') {
// https://apps.apple.com/app/apple-store/id1470168007
url_arr.insert(3, 'cn')

chrome.tabs.update(details.tabId, {url: url_arr.join('/')});
}
else {
else if (url_arr[3] !== 'cn'){
// https://apps.apple.com/us/app/spark-mail-email-by-readdle/id997102246
url_arr[3] = 'cn'
chrome.tabs.update(details.tabId, {url: url_arr.join('/')});
}

chrome.tabs.update(details.tabId, {url: url_arr.join('/')});
}

});

0 comments on commit 4d5ab16

Please sign in to comment.