Skip to content

Commit d6879d0

Browse files
committed
Replace Google Image Search with Google Lens because Google removed the old reverse search
Migration will be applied automatically for current users Fixes #61
1 parent dcb54bb commit d6879d0

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

background.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ var Provider = class Provider {
1111
};
1212

1313
const defaultProviders = [
14-
new Provider('Google', 'icons/google.png', 'https://www.google.com/searchbyimage?image_url=%s', true),
14+
new Provider('Google', 'icons/google.png', 'https://lens.google.com/uploadbyurl?url=%s', true),
1515
new Provider('IQDB', 'icons/iqdb.png', 'https://iqdb.org/?url=%s'),
1616
new Provider('TinEye', 'icons/tineye.png', 'https://www.tineye.com/search?url=%s'),
1717
new Provider('Bing', 'icons/bing.png', 'https://www.bing.com/images/searchbyimage?FORM=IRSBIQ&cbir=sbi&imgurl=%s'),
@@ -96,7 +96,15 @@ const defaultSettings = {
9696
If we don't, then store the default settings. */
9797
function checkStoredSettings(storedSettings) {
9898
if (Object.getOwnPropertyNames(storedSettings).length) {
99-
chrome.storage.sync.get(null, createContextMenu);
99+
chrome.storage.sync.get(null, (settings) => {
100+
for (let provider of settings.storageProviders) {
101+
if (provider.url === 'https://www.google.com/searchbyimage?image_url=%s') {
102+
provider.url = 'https://lens.google.com/uploadbyurl?url=%s';
103+
}
104+
}
105+
chrome.storage.sync.set(settings);
106+
createContextMenu(settings);
107+
});
100108
} else {
101109
chrome.storage.sync.set(defaultSettings);
102110
createContextMenu(defaultSettings);
@@ -144,13 +152,13 @@ function reverseSearch(info, storedSettings) {
144152
function openImageSearch(tabs) {
145153
const tabIndex = getTabIndex(openTabAt, tabs);
146154
const thisTab = tabs.filter(t => t.active)[0];
147-
155+
148156
for (const p of searchProviders) {
149157
chrome.tabs.create({
150158
url: p.replace('%s', encodeURIComponent(imageURL)),
151159
active: !openInBackground,
152160
index: tabIndex,
153-
openerTabId: thisTab.id,
161+
openerTabId: thisTab.id,
154162
});
155163
}
156164
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "__MSG_extensionName__",
55
"description": "__MSG_extensionDescription__",
66
"author": "Andreas Bielawski",
7-
"version": "3.4.0",
7+
"version": "3.4.1",
88
"icons": {
99
"16": "icons/16.png",
1010
"32": "icons/32.png",

0 commit comments

Comments
 (0)