diff --git a/extension.js b/extension.js index 59352be..30a1ff4 100644 --- a/extension.js +++ b/extension.js @@ -2,11 +2,11 @@ let loaded = false; let load_timeout = 2000; - function addHyperLinkMap(map, adress) { - if (map && adress) { + function addHyperLinkMap(map, address) { + if (map && address) { map.style.cursor = 'pointer'; map.addEventListener('click', () => { - window.location.href = adress.href; + window.location.href = address.href; }); } } @@ -20,16 +20,27 @@ } } - function addMapsToTabs(tabs, adress) { - const mapsTab = document.createElement('a'); - mapsTab.innerHTML = ` -
- Maps -
- `; - mapsTab.className = 'nPDzT T3FoJb'; - mapsTab.href = adress; - tabs.insertBefore(mapsTab, tabs.firstChild); + function addMapsToTabs(tabs, address, legacy) { + if (!legacy) { + const mapsTab = document.createElement('a'); + mapsTab.innerHTML = ` +
+ Maps +
+ `; + mapsTab.className = 'nPDzT T3FoJb'; + mapsTab.href = address; + tabs.insertBefore(mapsTab, tabs.firstChild); + } else { + const mapsTab = document.createElement('div'); + mapsTab.innerHTML = ` + +
Maps
+
+ `; + mapsTab.firstElementChild.href = address; + tabs.insertBefore(mapsTab, tabs.children[1]); + } } function formatSearchLink(search) { @@ -53,23 +64,32 @@ } function app() { - const search = document.querySelector('textarea.gLFyf'); - const tabs = document.querySelector('.IUOThf'); - const map = document.querySelector('.Ggdpnf'); - const adress = document.querySelector('.gqkR3b a'); - const largeMap = document.querySelector('.o8ebK'); + let legacy = false; + let tabs = document.querySelector('.IUOThf'); if (!tabs) { - return; + // Some of the Google domains use old UI + tabs = document.querySelector('.crJ18e'); + + if (!tabs) { + return + } + + legacy = true; } - if (map && adress) { - addHyperLinkMap(map, adress); - addMapsToTabs(tabs, adress.href); + const search = document.querySelector('textarea.gLFyf'); + const map = document.querySelector('.Ggdpnf'); + const address = document.querySelector('.gqkR3b a'); + const largeMap = document.querySelector('.o8ebK'); + + if (map && address) { + addHyperLinkMap(map, address); + addMapsToTabs(tabs, address.href, legacy); loaded = true; } else if (largeMap && search) { addHyperLinkLargeMap(largeMap, search); - addMapsToTabs(tabs, formatSearchLink(search.value)); + addMapsToTabs(tabs, formatSearchLink(search.value), legacy); loaded = true; } } diff --git a/manifest.json b/manifest.json index b1ad0c8..449102d 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "author": "thomasync", "description": "This extension brings back the old Google Search to include Google Maps results", "homepage_url": "https://github.com/thomasync/Bring-Back-Maps", - "version": "0.0.4", + "version": "0.0.5", "icons": { "1024": "icons/1024.png", "128": "icons/128.png", @@ -14,7 +14,195 @@ { "run_at": "document_start", "js": ["extension.js"], - "matches": ["https://www.google.fr/search*", "https://google.com/search*"] + "matches": [ + "https://*.google.com/search*", + "https://*.google.ad/search*", + "https://*.google.ae/search*", + "https://*.google.com.af/search*", + "https://*.google.com.ag/search*", + "https://*.google.al/search*", + "https://*.google.am/search*", + "https://*.google.co.ao/search*", + "https://*.google.com.ar/search*", + "https://*.google.as/search*", + "https://*.google.at/search*", + "https://*.google.com.au/search*", + "https://*.google.az/search*", + "https://*.google.ba/search*", + "https://*.google.com.bd/search*", + "https://*.google.be/search*", + "https://*.google.bf/search*", + "https://*.google.bg/search*", + "https://*.google.com.bh/search*", + "https://*.google.bi/search*", + "https://*.google.bj/search*", + "https://*.google.com.bn/search*", + "https://*.google.com.bo/search*", + "https://*.google.com.br/search*", + "https://*.google.bs/search*", + "https://*.google.bt/search*", + "https://*.google.co.bw/search*", + "https://*.google.by/search*", + "https://*.google.com.bz/search*", + "https://*.google.ca/search*", + "https://*.google.cd/search*", + "https://*.google.cf/search*", + "https://*.google.cg/search*", + "https://*.google.ch/search*", + "https://*.google.ci/search*", + "https://*.google.co.ck/search*", + "https://*.google.cl/search*", + "https://*.google.cm/search*", + "https://*.google.cn/search*", + "https://*.google.com.co/search*", + "https://*.google.co.cr/search*", + "https://*.google.com.cu/search*", + "https://*.google.cv/search*", + "https://*.google.com.cy/search*", + "https://*.google.cz/search*", + "https://*.google.de/search*", + "https://*.google.dj/search*", + "https://*.google.dk/search*", + "https://*.google.dm/search*", + "https://*.google.com.do/search*", + "https://*.google.dz/search*", + "https://*.google.com.ec/search*", + "https://*.google.ee/search*", + "https://*.google.com.eg/search*", + "https://*.google.es/search*", + "https://*.google.com.et/search*", + "https://*.google.fi/search*", + "https://*.google.com.fj/search*", + "https://*.google.fm/search*", + "https://*.google.fr/search*", + "https://*.google.ga/search*", + "https://*.google.ge/search*", + "https://*.google.gg/search*", + "https://*.google.com.gh/search*", + "https://*.google.com.gi/search*", + "https://*.google.gl/search*", + "https://*.google.gm/search*", + "https://*.google.gr/search*", + "https://*.google.com.gt/search*", + "https://*.google.gy/search*", + "https://*.google.com.hk/search*", + "https://*.google.hn/search*", + "https://*.google.hr/search*", + "https://*.google.ht/search*", + "https://*.google.hu/search*", + "https://*.google.co.id/search*", + "https://*.google.ie/search*", + "https://*.google.co.il/search*", + "https://*.google.im/search*", + "https://*.google.co.in/search*", + "https://*.google.iq/search*", + "https://*.google.is/search*", + "https://*.google.it/search*", + "https://*.google.je/search*", + "https://*.google.com.jm/search*", + "https://*.google.jo/search*", + "https://*.google.co.jp/search*", + "https://*.google.co.ke/search*", + "https://*.google.com.kh/search*", + "https://*.google.ki/search*", + "https://*.google.kg/search*", + "https://*.google.co.kr/search*", + "https://*.google.com.kw/search*", + "https://*.google.kz/search*", + "https://*.google.la/search*", + "https://*.google.com.lb/search*", + "https://*.google.li/search*", + "https://*.google.lk/search*", + "https://*.google.co.ls/search*", + "https://*.google.lt/search*", + "https://*.google.lu/search*", + "https://*.google.lv/search*", + "https://*.google.com.ly/search*", + "https://*.google.co.ma/search*", + "https://*.google.md/search*", + "https://*.google.me/search*", + "https://*.google.mg/search*", + "https://*.google.mk/search*", + "https://*.google.ml/search*", + "https://*.google.com.mm/search*", + "https://*.google.mn/search*", + "https://*.google.com.mt/search*", + "https://*.google.mu/search*", + "https://*.google.mv/search*", + "https://*.google.mw/search*", + "https://*.google.com.mx/search*", + "https://*.google.com.my/search*", + "https://*.google.co.mz/search*", + "https://*.google.com.na/search*", + "https://*.google.com.ng/search*", + "https://*.google.com.ni/search*", + "https://*.google.ne/search*", + "https://*.google.nl/search*", + "https://*.google.no/search*", + "https://*.google.com.np/search*", + "https://*.google.nr/search*", + "https://*.google.nu/search*", + "https://*.google.co.nz/search*", + "https://*.google.com.om/search*", + "https://*.google.com.pa/search*", + "https://*.google.com.pe/search*", + "https://*.google.com.pg/search*", + "https://*.google.com.ph/search*", + "https://*.google.com.pk/search*", + "https://*.google.pl/search*", + "https://*.google.pn/search*", + "https://*.google.com.pr/search*", + "https://*.google.ps/search*", + "https://*.google.pt/search*", + "https://*.google.com.py/search*", + "https://*.google.com.qa/search*", + "https://*.google.ro/search*", + "https://*.google.ru/search*", + "https://*.google.rw/search*", + "https://*.google.com.sa/search*", + "https://*.google.com.sb/search*", + "https://*.google.sc/search*", + "https://*.google.se/search*", + "https://*.google.com.sg/search*", + "https://*.google.sh/search*", + "https://*.google.si/search*", + "https://*.google.sk/search*", + "https://*.google.com.sl/search*", + "https://*.google.sn/search*", + "https://*.google.so/search*", + "https://*.google.sm/search*", + "https://*.google.sr/search*", + "https://*.google.st/search*", + "https://*.google.com.sv/search*", + "https://*.google.td/search*", + "https://*.google.tg/search*", + "https://*.google.co.th/search*", + "https://*.google.com.tj/search*", + "https://*.google.tl/search*", + "https://*.google.tm/search*", + "https://*.google.tn/search*", + "https://*.google.to/search*", + "https://*.google.com.tr/search*", + "https://*.google.tt/search*", + "https://*.google.com.tw/search*", + "https://*.google.co.tz/search*", + "https://*.google.com.ua/search*", + "https://*.google.co.ug/search*", + "https://*.google.co.uk/search*", + "https://*.google.com.uy/search*", + "https://*.google.co.uz/search*", + "https://*.google.com.vc/search*", + "https://*.google.co.ve/search*", + "https://*.google.co.vi/search*", + "https://*.google.com.vn/search*", + "https://*.google.vu/search*", + "https://*.google.ws/search*", + "https://*.google.rs/search*", + "https://*.google.co.za/search*", + "https://*.google.co.zm/search*", + "https://*.google.co.zw/search*", + "https://*.google.cat/search*" + ] } ], "permissions": []