parent
576dfd3c5d
commit
8b8c0d64f4
@ -0,0 +1,40 @@ |
||||
import { Country } from '@/classes/Enum/Country' |
||||
|
||||
export class CountryResolver { |
||||
resolve (): Promise<Country> { |
||||
const promise = new Promise((resolve) => { |
||||
if (typeof chrome.tabs === 'undefined') { |
||||
const country = this.grabCountry(location.href || '') |
||||
resolve(country) |
||||
return |
||||
} |
||||
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { |
||||
for (const tab of tabs) { |
||||
const country = this.grabCountry(tab.url || '') |
||||
resolve(country) |
||||
return |
||||
} |
||||
}) |
||||
}) |
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
|
||||
// @ts-ignore
|
||||
return promise.then((country) => { |
||||
console.log('country', country) |
||||
return country |
||||
}) |
||||
} |
||||
|
||||
grabCountry (url: string): Country { |
||||
const isNordecum = url.indexOf('smspinigai') > -1 || |
||||
url.indexOf('paskolos') > -1 || |
||||
url.indexOf('nordecum') > -1 |
||||
|
||||
if (isNordecum) { |
||||
return Country.LITHUANIA |
||||
} |
||||
|
||||
return Country.ESTONIA |
||||
} |
||||
} |
||||
|
||||
export default new CountryResolver() |
Loading…
Reference in new issue