parent
ae75816951
commit
77408cdb73
@ -0,0 +1,42 @@ |
||||
export class DomainResolver { |
||||
resolve (): Promise<string> { |
||||
const promise = new Promise((resolve) => { |
||||
if (typeof chrome === 'undefined') { |
||||
resolve(null) |
||||
return |
||||
} |
||||
if (typeof chrome.tabs === 'undefined') { |
||||
resolve(null) |
||||
return |
||||
} |
||||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { |
||||
for (const tab of tabs) { |
||||
let url = tab.url || '' |
||||
const parts = url.match(/http:\/\/.*?\.(.*?)\..*?/) || [] |
||||
const nickname = parts[1] || null |
||||
const isPlacetgroup = url.indexOf('laen') > -1 || |
||||
url.indexOf('smsmoney') > -1 || |
||||
url.indexOf('smsraha') > -1 || |
||||
url.indexOf('placetgroup') > -1 |
||||
const project = isPlacetgroup ? 'placetgroup' : 'nordecum' |
||||
const domain = isPlacetgroup ? 'com' : 'lt' |
||||
if (nickname && url.indexOf('.sv') > -1) { |
||||
url = project + '.' + nickname + '.sv' |
||||
} else { |
||||
url = project + '.' + nickname + '.' + domain |
||||
} |
||||
resolve(url) |
||||
return |
||||
} |
||||
}) |
||||
}) |
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
||||
// @ts-ignore
|
||||
return promise.then((url) => { |
||||
console.log('url', url) |
||||
return url |
||||
}) |
||||
} |
||||
} |
||||
|
||||
export default new DomainResolver() |
Loading…
Reference in new issue