-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbackground.js
More file actions
24 lines (22 loc) · 857 Bytes
/
background.js
File metadata and controls
24 lines (22 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Array.prototype.insert = function ( index, item ) {
this.splice( index, 0, item );
};
chrome.webNavigation.onBeforeNavigate.addListener(function(details)
{
if (details.frameId != 0) //ignore subframes. 0 is main frame
{ return; }
if (details.url.startsWith('https://apps.apple.com/')) {
// console.log(details.url.split('/'))
url_arr = details.url.split('/')
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('/')});
}
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('/')});
}
}
});