Skip to content

Commit

Permalink
fix: remove Google Cache and Yahoo Cache
Browse files Browse the repository at this point in the history
Closes #90.
  • Loading branch information
dessant committed Sep 28, 2024
1 parent 7869d64 commit b48f6d6
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 204 deletions.
34 changes: 0 additions & 34 deletions src/assets/icons/engines/google.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/assets/icons/engines/yahoo-dark.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/assets/icons/engines/yahoo.svg

This file was deleted.

17 changes: 1 addition & 16 deletions src/assets/locales/en/messages-firefox.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"engineName_googleText": {
"message": "Google (Text-Only)",
"description": "Name of the search engine."
},

"engineName_archiveIsAll": {
"message": "Archive.is (All)",
"description": "Name of the search engine."
Expand All @@ -14,11 +9,6 @@
"description": "Name of the search engine."
},

"menuItemTitle_googleText": {
"message": "Google (Text-Only)",
"description": "Name of the search engine."
},

"menuItemTitle_archiveIsAll": {
"message": "Archive.is (All)",
"description": "Name of the search engine."
Expand All @@ -45,7 +35,7 @@
"placeholders": {
"engine": {
"content": "$1",
"example": "Google"
"example": "Wayback Machine"
}
}
},
Expand All @@ -60,11 +50,6 @@
"description": "Title of the options section."
},

"optionTitle_googleText": {
"message": "Google Cache (Text-Only)",
"description": "Title of the option."
},

"optionTitle_archiveOrgAll": {
"message": "Wayback Machine (All)",
"description": "Title of the option."
Expand Down
17 changes: 1 addition & 16 deletions src/assets/locales/en/messages-safari.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
"description": "Description of the extension."
},

"engineName_googleText": {
"message": "Google (Text-Only)",
"description": "Name of the search engine."
},

"engineName_archiveIsAll": {
"message": "Archive.is (All)",
"description": "Name of the search engine."
Expand All @@ -19,11 +14,6 @@
"description": "Name of the search engine."
},

"menuItemTitle_googleText": {
"message": "Google (Text-Only)",
"description": "Title of the menu item."
},

"menuItemTitle_archiveIsAll": {
"message": "Archive.is (All)",
"description": "Title of the menu item."
Expand All @@ -50,7 +40,7 @@
"placeholders": {
"engine": {
"content": "$1",
"example": "Google"
"example": "Wayback Machine"
}
}
},
Expand All @@ -65,11 +55,6 @@
"description": "Title of the options section."
},

"optionTitle_googleText": {
"message": "Google Cache (Text-Only)",
"description": "Title of the option."
},

"optionTitle_archiveOrgAll": {
"message": "Wayback Machine (All)",
"description": "Title of the option."
Expand Down
55 changes: 5 additions & 50 deletions src/assets/locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,10 @@
},

"extensionDescription": {
"message": "View archived and cached versions of web pages on 10+ search engines, such as the Wayback Machine, Archive.is and Google.",
"message": "View archived and cached versions of web pages on 10+ search engines, such as the Wayback Machine and Archive.is.",
"description": "Description of the extension."
},

"engineName_google": {
"message": "Google",
"description": "Name of the search engine."
},

"engineName_googleText": {
"message": "Google (text-only)",
"description": "Name of the search engine."
},

"engineName_bing": {
"message": "Bing",
"description": "Name of the search engine."
Expand Down Expand Up @@ -59,11 +49,6 @@
"description": "Name of the search engine."
},

"engineName_yahoo": {
"message": "Yahoo",
"description": "Name of the search engine."
},

"engineName_permacc": {
"message": "Perma.cc",
"description": "Name of the search engine."
Expand Down Expand Up @@ -95,21 +80,11 @@
"placeholders": {
"engine": {
"content": "$1",
"example": "Google"
"example": "Wayback Machine"
}
}
},

"menuItemTitle_google": {
"message": "Google",
"description": "Title of the menu item."
},

"menuItemTitle_googleText": {
"message": "Google (text-only)",
"description": "Title of the menu item."
},

"menuItemTitle_bing": {
"message": "Bing",
"description": "Title of the menu item."
Expand Down Expand Up @@ -150,11 +125,6 @@
"description": "Title of the menu item."
},

"menuItemTitle_yahoo": {
"message": "Yahoo",
"description": "Title of the menu item."
},

"menuItemTitle_permacc": {
"message": "Perma.cc",
"description": "Title of the menu item."
Expand Down Expand Up @@ -186,7 +156,7 @@
"placeholders": {
"engine": {
"content": "$1",
"example": "Google"
"example": "Wayback Machine"
}
}
},
Expand All @@ -206,16 +176,6 @@
"description": "Description of the options section."
},

"optionTitle_google": {
"message": "Google Cache",
"description": "Title of the option."
},

"optionTitle_googleText": {
"message": "Google Cache (text-only)",
"description": "Title of the option."
},

"optionTitle_bing": {
"message": "Bing Cache",
"description": "Title of the option."
Expand Down Expand Up @@ -256,11 +216,6 @@
"description": "Title of the option."
},

"optionTitle_yahoo": {
"message": "Yahoo Cache",
"description": "Title of the option."
},

"optionTitle_permacc": {
"message": "Perma.cc",
"description": "Title of the option."
Expand Down Expand Up @@ -552,7 +507,7 @@
"placeholders": {
"engine": {
"content": "$1",
"example": "Google"
"example": "Wayback Machine"
}
}
},
Expand All @@ -563,7 +518,7 @@
"placeholders": {
"engine": {
"content": "$1",
"example": "Google"
"example": "Wayback Machine"
}
}
},
Expand Down
16 changes: 2 additions & 14 deletions src/background/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import {
pageArchiveHosts,
linkArchiveHosts,
linkArchiveUrlRx,
chromeMobileUA,
chromeDesktopUA
} from 'utils/data';
import {targetEnv, mv3} from 'utils/config';
Expand Down Expand Up @@ -625,11 +624,7 @@ async function setTabUserAgent({tabId, tabUrl, userAgent, beaconToken} = {}) {

async function getRequiredUserAgent(engine) {
if (await isMobile()) {
// Google only works with a Chrome user agent on Firefox for Android,
// while other search engines may need a desktop user agent.
if (targetEnv === 'firefox' && ['google', 'googleText'].includes(engine)) {
return chromeMobileUA;
} else if (['yandex', 'bing', 'yahoo'].includes(engine)) {
if (['yandex', 'bing'].includes(engine)) {
return chromeDesktopUA;
}
}
Expand All @@ -653,14 +648,7 @@ async function openCurrentDoc({linkUrl} = {}) {
for (const [engine, rx] of Object.entries(linkArchiveUrlRx)) {
const match = linkUrl.match(rx);
if (match) {
if (engine === 'google') {
const data = new URL(linkUrl).searchParams.get('q');
if (data) {
docUrl = data.replace(/^cache.*?(https?:\/\/.*)$/, '$1').trim();
}
} else {
docUrl = match[1].trim();
}
docUrl = match[1].trim();

break;
}
Expand Down
43 changes: 0 additions & 43 deletions src/engines/yahoo.js

This file was deleted.

7 changes: 3 additions & 4 deletions src/storage/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@
"20230715152710_add_ghostarchive",
"20230718120215_add_webcite",
"20240514170322_add_appversion",
"20240619180111_add_menuchangeevent"
"20240619180111_add_menuchangeevent",
"20240928183956_remove_search_engines"
],
"session": [
"20240514122825_initial_version"
]
"session": ["20240514122825_initial_version"]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const message = 'Remove search engines';

const revision = '20240928183956_remove_search_engines';

async function upgrade(context) {
const changes = {};
const {engines, disabledEngines} = await browser.storage.local.get([
'engines',
'disabledEngines'
]);

const removeEngines = ['google', 'googleText', 'yahoo'];
const enableEngines = [];

if (context.install) {
enableEngines.push('ghostarchive', 'webcite');
}

changes.engines = engines.filter(function (item) {
return !removeEngines.includes(item);
});
changes.disabledEngines = disabledEngines.filter(function (item) {
return !removeEngines.includes(item) && !enableEngines.includes(item);
});

changes.storageVersion = revision;
return browser.storage.local.set(changes);
}

export {message, revision, upgrade};
4 changes: 0 additions & 4 deletions src/tools/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ function main() {
docUrl = document.querySelector(
'#HEADER form[action*="/search/"] input[type=text]'
)?.value;
} else if (engine === 'google') {
docUrl = document.querySelector(
'[id*="google-cache-hdr"] > div > span > a'
)?.href;
} else if (engine === 'bing') {
docUrl = document.querySelector(
'div.b_vPanel > div > strong > a[h*="ID=SERP"]'
Expand Down
Loading

0 comments on commit b48f6d6

Please sign in to comment.