Skip to content

Commit

Permalink
Redirect all engines to Kagi by default (#73)
Browse files Browse the repository at this point in the history
Will reduce likelihood of issues like https://kagifeedback.org/d/3320-latest-safari-extension-222, but risks increasing reports of https://kagifeedback.org/d/3164-google-bang-does-not-work-on-ios

Bumped version to 2.2.3 (25)
  • Loading branch information
workwithnano authored May 21, 2024
1 parent 5a2ba75 commit 8934a2d
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 84 deletions.

This file was deleted.

4 changes: 2 additions & 2 deletions safari/Universal/MainConfig.xcconfig
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
MARKETING_VERSION = 2.2.2
CURRENT_PROJECT_VERSION = 24 // this needs to be increased with each version change as well (not set to 1 when version is updated)
MARKETING_VERSION = 2.2.3
CURRENT_PROJECT_VERSION = 25 // this needs to be increased with each version change as well (not set to 1 when version is updated)
PRODUCT_NAME = Kagi for Safari
10 changes: 5 additions & 5 deletions safari/Universal/Shared (Extension)/Resources/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ function domainKeyForHost(knownHost) {
}
return "";
}
const supportedEngineNames = Object.keys(domainMap);
const supportedEngineNames = Object.keys(domainMap).concat(["All"]);
const www = "www.";
const yahoo = "search.yahoo.com";
const extensionId = "com.kagi.Kagi-Search-for-Safari.Extension (TFVG979488)";
Expand All @@ -309,7 +309,7 @@ var ua = {},
os = !0,
rs = !0,
currentEngine = "All",
defaultEngineToRedirect = "Google",
defaultEngineToRedirect = "All",
defaultKagiSearchTemplate = "https://kagi.com/search?q=%s",
kagiSearchTemplate = defaultKagiSearchTemplate,
kagiPrivateSearchTemplate = "",
Expand Down Expand Up @@ -339,7 +339,7 @@ function captureQuery(a) {
b.endsWith(yahoo) && (b = yahoo);
const path = a.pathname;
var shouldBlockGoogleNonSearch = (b in googleUrls && !(path.startsWith("/search")));
var shouldBlockRedirectBasedOnUserPreference = ([currentEngine, "All"].indexOf(domainKeyForHost(b)) < 0);
var shouldBlockRedirectBasedOnUserPreference = (currentEngine != "All" && currentEngine != domainKeyForHost(b));
if (b in builtInEngines && !(shouldBlockGoogleNonSearch || shouldBlockRedirectBasedOnUserPreference) && (a = (new URLSearchParams(a.search)).get(builtInEngines[b]))) return a;
}

Expand Down Expand Up @@ -447,8 +447,8 @@ function getPreferencesFromStorage(callback) {
// Engine to redirect
var engine = value.kagiEngineToRedirect;
if (typeof (engine) == "string") {
if (engine == "All" || supportedEngineNames.indexOf(engine) < 0) {
currentEngine = defaultEngineToRedirect; // default to redirecting Google
if (supportedEngineNames.indexOf(engine) < 0) {
currentEngine = defaultEngineToRedirect; // default to redirecting All engines to Kagi
} else {
currentEngine = engine;
}
Expand Down
1 change: 1 addition & 0 deletions safari/Universal/Shared (Extension)/Resources/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ <h4>Engine to redirect</h4>
<p>Select the search engine you want to redirect to Kagi.</p>
<fieldset>
<select type="text" id="engine-to-redirect">
<option value="All" name="All">All Search Engines</option>
<option value="Google" name="Google">Google</option>
<option value="DuckDuckGo" name="DuckDuckGo">DuckDuckGo</option>
<option value="Yahoo" name="Yahoo">Yahoo</option>
Expand Down
6 changes: 3 additions & 3 deletions safari/Universal/Shared (Extension)/Resources/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ document.querySelector("#private-session-link").addEventListener('paste', privat
// -----------------------
// MARK: - Selecting default engine to redirect
// -----------------------
var engineToRedirect = "All";
const defaultEngineToRedirect = "Google";
const defaultEngineToRedirect = "All";
var engineToRedirect = defaultEngineToRedirect;
const engineSelect = document.getElementById('engine-to-redirect');

// Updates the UI
Expand Down Expand Up @@ -129,7 +129,7 @@ function fetchAndUpdateKnownHostList() {

// If the currently-redirecting engine no longer has permissions in the extension,
// reset to "All"
let enginesToDisplayInRedirectList = Array.from(document.querySelectorAll("[data-engine]")).map((en) => en.getAttribute("data-engine"));
let enginesToDisplayInRedirectList = ["All"].concat(Array.from(document.querySelectorAll("[data-engine]")).map((en) => en.getAttribute("data-engine")));
if (engineToRedirect != "All" && enginesToDisplayInRedirectList.indexOf(engineToRedirect) < 0) {
engineToRedirect = "All";
}
Expand Down
2 changes: 1 addition & 1 deletion safari/Universal/iOS (Extension)/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"name": "__MSG_extension_name__",
"description": "__MSG_extension_description__",
"version": "2.2.2",
"version": "2.2.3",

"icons": {
"512": "images/Icon.png"
Expand Down
2 changes: 1 addition & 1 deletion safari/Universal/macOS (Extension)/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

"name": "__MSG_extension_name__",
"description": "__MSG_extension_description__",
"version": "2.2.2",
"version": "2.2.3",

"icons": {
"512": "images/Icon.png"
Expand Down

0 comments on commit 8934a2d

Please sign in to comment.