diff --git a/README.MD b/README.MD index 0b590eb..c1939aa 100644 --- a/README.MD +++ b/README.MD @@ -15,3 +15,4 @@ You can get this extension for Firefox or Chrome or as a userscript: ### Credits - More accurate URL collection thanks to [devunt](https://github.com/devunt)/[make-gis-great-again](https://github.com/devunt/make-gis-great-again) - Icon by [Daniel Hickman](https://github.com/danielhickman) +- Modern Google Images layout compatibility updates by [martigironest](https://github.com/martigironest) diff --git a/js/content-script.js b/js/content-script.js index 90a1df9..e5114b9 100644 --- a/js/content-script.js +++ b/js/content-script.js @@ -1,7 +1,7 @@ 'use strict'; -const DEBUG = false; -const TRACE = DEBUG && false; +const DEBUG = true; +const TRACE = DEBUG && true; const VERSIONS = { FEB18: 'FEB18', @@ -33,7 +33,13 @@ function getContainer(node) { ['.irc_c[data-ved]', VERSIONS.JUL19], ['.tvh9oe[style*="display: block;"]', VERSIONS.OCT19], ['.EIehLd[style*="display: block;"]', VERSIONS.OCT19], - ['.fHE6De[style*="display: block;"]', VERSIONS.OCT19] + ['.fHE6De[style*="display: block;"]', VERSIONS.OCT19], + ['.tvh9oe', VERSIONS.OCT19], + ['.EIehLd', VERSIONS.OCT19], + ['.fHE6De', VERSIONS.OCT19], + ['.hh1Ztf', VERSIONS.OCT19], + ['.ip4nvd', VERSIONS.OCT19], + ['.cLqwWc', VERSIONS.OCT19] ].forEach(element => { var child = node.querySelector(element[0]); if (child) { @@ -89,10 +95,11 @@ function findImageURL(container, version) { image = iframe.contentDocument.querySelector('img#irc_mi'); break; case VERSIONS.OCT19: - image = container.querySelector('img[src][style][jsaction]'); - if (image.src in images) { + image = container.querySelector('img[src][style][jsaction], img.n3VNCb, img.r4a1G, img.sFlh5c, img.FyHeAf, img.iPVvYb'); + if (image && image.src in images) { return images[image.src]; } + break; } // Override url for images using base64 embeds @@ -153,6 +160,9 @@ function addViewImageButton(container, node, imageURL, version) { var nodeRoot = node.parentElement.parentElement; var visitButtons = [ + container.querySelector('.h11UTe a.umNKYc'), + container.querySelector('.h11UTe a > div')?.parentElement, + container.querySelector('a > div > span + svg')?.parentElement?.parentElement, nodeRoot?.parentElement?.nextSibling?.querySelector?.('a > div > span + svg')?.parentElement?.parentElement, nodeRoot?.parentElement?.nextSibling?.nextSibling?.querySelector?.('a > div > span + svg')?.parentElement?.parentElement, nodeRoot?.nextSibling?.nextSibling?.querySelector?.('a > div > span + svg')?.parentElement?.parentElement, @@ -466,10 +476,10 @@ try { function processNode(node) { - var imageNodes = document.querySelectorAll('img[src][style][jsaction]'); + var imageNodes = document.querySelectorAll('img[src][style][jsaction], img.n3VNCb, img.r4a1G, img.sFlh5c'); for (var i = 0; i < imageNodes.length; i++) { var imageNode = imageNodes[i]; - if (nodeIsVisible(imageNode) && node.contains(imageNode) && addLinks(node)) { + if (nodeIsVisible(imageNode) && node.contains(imageNode) && addLinks(imageNode)) { return; } } diff --git a/manifest.json b/manifest.json new file mode 100644 index 0000000..5235240 --- /dev/null +++ b/manifest.json @@ -0,0 +1,230 @@ +{ + "manifest_version": 3, + "name": "__MSG_appName__", + "version": "5.2.0", + "description": "__MSG_appDesc__", + "default_locale": "en", + "icons": { + "16": "icon/16.png", + "19": "icon/19.png", + "38": "icon/38.png", + "48": "icon/48.png", + "128": "icon/128.png" + }, + "author": "Joshua Butt", + "action": { + "default_icon": "icon/48.png", + "default_popup": "html/popup.html" + }, + "permissions": [ + "storage" + ], + "options_ui": { + "page": "html/options.html" + }, + "content_scripts": [ + { + "js": [ + "js/content-script.js" + ], + "matches": [ + "*://*.google.com/*", + "*://*.google.ad/*", + "*://*.google.ae/*", + "*://*.google.com.af/*", + "*://*.google.com.ag/*", + "*://*.google.al/*", + "*://*.google.am/*", + "*://*.google.co.ao/*", + "*://*.google.com.ar/*", + "*://*.google.as/*", + "*://*.google.at/*", + "*://*.google.com.au/*", + "*://*.google.az/*", + "*://*.google.ba/*", + "*://*.google.com.bd/*", + "*://*.google.be/*", + "*://*.google.bf/*", + "*://*.google.bg/*", + "*://*.google.com.bh/*", + "*://*.google.bi/*", + "*://*.google.bj/*", + "*://*.google.com.bn/*", + "*://*.google.com.bo/*", + "*://*.google.com.br/*", + "*://*.google.bs/*", + "*://*.google.bt/*", + "*://*.google.co.bw/*", + "*://*.google.by/*", + "*://*.google.com.bz/*", + "*://*.google.ca/*", + "*://*.google.cd/*", + "*://*.google.cf/*", + "*://*.google.cg/*", + "*://*.google.ch/*", + "*://*.google.ci/*", + "*://*.google.co.ck/*", + "*://*.google.cl/*", + "*://*.google.cm/*", + "*://*.google.cn/*", + "*://*.google.com.co/*", + "*://*.google.co.cr/*", + "*://*.google.com.cu/*", + "*://*.google.cv/*", + "*://*.google.com.cy/*", + "*://*.google.cz/*", + "*://*.google.de/*", + "*://*.google.dj/*", + "*://*.google.dk/*", + "*://*.google.dm/*", + "*://*.google.com.do/*", + "*://*.google.dz/*", + "*://*.google.com.ec/*", + "*://*.google.ee/*", + "*://*.google.com.eg/*", + "*://*.google.es/*", + "*://*.google.com.et/*", + "*://*.google.fi/*", + "*://*.google.com.fj/*", + "*://*.google.fm/*", + "*://*.google.fr/*", + "*://*.google.ga/*", + "*://*.google.ge/*", + "*://*.google.gg/*", + "*://*.google.com.gh/*", + "*://*.google.com.gi/*", + "*://*.google.gl/*", + "*://*.google.gm/*", + "*://*.google.gr/*", + "*://*.google.com.gt/*", + "*://*.google.gy/*", + "*://*.google.com.hk/*", + "*://*.google.hn/*", + "*://*.google.hr/*", + "*://*.google.ht/*", + "*://*.google.hu/*", + "*://*.google.co.id/*", + "*://*.google.ie/*", + "*://*.google.co.il/*", + "*://*.google.im/*", + "*://*.google.co.in/*", + "*://*.google.iq/*", + "*://*.google.is/*", + "*://*.google.it/*", + "*://*.google.je/*", + "*://*.google.com.jm/*", + "*://*.google.jo/*", + "*://*.google.co.jp/*", + "*://*.google.co.ke/*", + "*://*.google.com.kh/*", + "*://*.google.ki/*", + "*://*.google.kg/*", + "*://*.google.co.kr/*", + "*://*.google.com.kw/*", + "*://*.google.kz/*", + "*://*.google.la/*", + "*://*.google.com.lb/*", + "*://*.google.li/*", + "*://*.google.lk/*", + "*://*.google.co.ls/*", + "*://*.google.lt/*", + "*://*.google.lu/*", + "*://*.google.lv/*", + "*://*.google.com.ly/*", + "*://*.google.co.ma/*", + "*://*.google.md/*", + "*://*.google.me/*", + "*://*.google.mg/*", + "*://*.google.mk/*", + "*://*.google.ml/*", + "*://*.google.com.mm/*", + "*://*.google.mn/*", + "*://*.google.com.mt/*", + "*://*.google.mu/*", + "*://*.google.mv/*", + "*://*.google.mw/*", + "*://*.google.com.mx/*", + "*://*.google.com.my/*", + "*://*.google.co.mz/*", + "*://*.google.com.na/*", + "*://*.google.com.ng/*", + "*://*.google.com.ni/*", + "*://*.google.ne/*", + "*://*.google.nl/*", + "*://*.google.no/*", + "*://*.google.com.np/*", + "*://*.google.nr/*", + "*://*.google.nu/*", + "*://*.google.co.nz/*", + "*://*.google.com.om/*", + "*://*.google.com.pa/*", + "*://*.google.com.pe/*", + "*://*.google.com.pg/*", + "*://*.google.com.ph/*", + "*://*.google.com.pk/*", + "*://*.google.pl/*", + "*://*.google.pn/*", + "*://*.google.com.pr/*", + "*://*.google.ps/*", + "*://*.google.pt/*", + "*://*.google.com.py/*", + "*://*.google.com.qa/*", + "*://*.google.ro/*", + "*://*.google.ru/*", + "*://*.google.rw/*", + "*://*.google.com.sa/*", + "*://*.google.com.sb/*", + "*://*.google.sc/*", + "*://*.google.se/*", + "*://*.google.com.sg/*", + "*://*.google.sh/*", + "*://*.google.si/*", + "*://*.google.sk/*", + "*://*.google.com.sl/*", + "*://*.google.sn/*", + "*://*.google.so/*", + "*://*.google.sm/*", + "*://*.google.sr/*", + "*://*.google.st/*", + "*://*.google.com.sv/*", + "*://*.google.td/*", + "*://*.google.tg/*", + "*://*.google.co.th/*", + "*://*.google.com.tj/*", + "*://*.google.tl/*", + "*://*.google.tm/*", + "*://*.google.tn/*", + "*://*.google.to/*", + "*://*.google.com.tr/*", + "*://*.google.tt/*", + "*://*.google.com.tw/*", + "*://*.google.co.tz/*", + "*://*.google.com.ua/*", + "*://*.google.co.ug/*", + "*://*.google.co.uk/*", + "*://*.google.com.uy/*", + "*://*.google.co.uz/*", + "*://*.google.com.vc/*", + "*://*.google.co.ve/*", + "*://*.google.co.vi/*", + "*://*.google.com.vn/*", + "*://*.google.vu/*", + "*://*.google.ws/*", + "*://*.google.rs/*", + "*://*.google.co.za/*", + "*://*.google.co.zm/*", + "*://*.google.co.zw/*", + "*://*.google.cat/*" + ], + "include_globs": [ + "*tbm=isch*", + "*imgres?*", + "*udm=2*" + ] + } + ], + "background": { + "service_worker": "js/background.js", + "type": "module" + } +} \ No newline at end of file