-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Safari Extensions to repo * Delete .DS_Store that snuck in
- Loading branch information
1 parent
28828d0
commit b8baeed
Showing
196 changed files
with
7,819 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.DS_Store | ||
*.xcuserdatad |
Binary file added
BIN
+176 KB
...Screenshot - iPad Pro (12.9-inch) (2nd generation) - 2024-01-01 at 23.07.55.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+176 KB
...Screenshot - iPad Pro (12.9-inch) (6th generation) - 2024-01-01 at 23.08.32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+194 KB
... Screenshots/Simulator Screenshot - iPhone 15 Plus - 2024-01-01 at 22.56.32.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+292 KB
... Screenshots/Simulator Screenshot - iPhone 15 Plus - 2024-01-01 at 22.56.44.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+249 KB
... Screenshots/Simulator Screenshot - iPhone 15 Plus - 2024-01-01 at 22.56.59.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+170 KB
...e Screenshots/Simulator Screenshot - iPhone 8 Plus - 2024-01-01 at 23.02.04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+239 KB
...e Screenshots/Simulator Screenshot - iPhone 8 Plus - 2024-01-01 at 23.04.12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+236 KB
...e Screenshots/Simulator Screenshot - iPhone 8 Plus - 2024-01-01 at 23.04.26.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+95.4 KB
.../Simulator Screenshot - iPhone SE (3rd generation) - 2024-01-01 at 22.57.50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+118 KB
.../Simulator Screenshot - iPhone SE (3rd generation) - 2024-01-01 at 22.58.42.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+125 KB
.../Simulator Screenshot - iPhone SE (3rd generation) - 2024-01-01 at 22.59.19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.Safari.web-extension</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).SafariWebExtensionHandler</string> | ||
</dict> | ||
</dict> | ||
</plist> |
10 changes: 10 additions & 0 deletions
10
safari/Legacy iOS/KagiForSafari Extension/Resources/_locales/en/messages.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"extension_name": { | ||
"message": "Kagi Search", | ||
"description": "..." | ||
}, | ||
"extension_description": { | ||
"message": "With Kagi Search extension you can get your search queries sent to Kagi while using Safari.", | ||
"description": "..." | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
safari/Legacy iOS/KagiForSafari Extension/Resources/background.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
chrome.webNavigation.onBeforeNavigate.addListener(function(details) { | ||
let url = details.url; | ||
if (typeof(url) !== "undefined" && url.startsWith(`https://kagi.com`)) { | ||
chrome.storage.local.set({ lastKagiUrl: url }); | ||
} else { | ||
chrome.storage.local.set({ lastKagiUrl: "" }); | ||
} | ||
}); |
113 changes: 113 additions & 0 deletions
113
safari/Legacy iOS/KagiForSafari Extension/Resources/content.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
const searchQuery = navigateIfNeeded(window.location); | ||
|
||
if (window.location.href.startsWith("https://kagi.com/")) { | ||
if (window.location.href.startsWith("https://kagi.com/signin") && getCookie("extRedirected") == "") { | ||
setCookie("extRedirected", "1"); | ||
chrome.storage.local.get(["privateSessionLink", "lastKagiUrl"], function(value) { | ||
var privateSessionLink = value.privateSessionLink; | ||
var lastKagiUrl = value.lastKagiUrl; | ||
var searchQuery = getParameterByName("q", lastKagiUrl) | ||
if (typeof(privateSessionLink) !== "undefined" && privateSessionLink.startsWith(`https://kagi.com/`)) { | ||
if (privateSessionLink.includes("q=%s")) { | ||
window.location.replace(privateSessionLink.replace("%s", searchQuery != null ? searchQuery : "")); | ||
} else { | ||
window.location.replace(privateSessionLink.concat("&q=", searchQuery != null ? searchQuery : "")); | ||
} | ||
} | ||
}); | ||
} else { | ||
setCookie("extRedirected", ""); | ||
} | ||
} else if (searchQuery != null) { | ||
if (!shouldSkipRedirect()) { | ||
window.location.replace(`https://kagi.com/search?q=${searchQuery}`); | ||
} | ||
} | ||
|
||
function shouldSkipRedirect(url = window.location.href) { | ||
var result = false; | ||
const host = location.host.replace("www.", ""); | ||
if (host.includes("google.") && getParameterByName("client") == null) { | ||
result = true; | ||
} else if (host.includes("bing.") && getParameterByName("form") == null) { | ||
result = true; | ||
} else if (host.includes("duckduckgo.") && getParameterByName("t") == null) { | ||
result = true; | ||
} else if (host.includes("search.yahoo.") && getParameterByName("fr") == null) { | ||
result = true; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
function navigateIfNeeded(location) { | ||
var result = null; | ||
const host = location.host.replace("www.", ""); | ||
|
||
["google.", "bing.", "ecosia.", "search.yahoo"].forEach(function(item){ | ||
if (host.includes(item)) { | ||
if (location.pathname === "/search") { | ||
result = getParameterByName((host.includes("search.yahoo")) ? "p" : "q"); | ||
} | ||
} | ||
}); | ||
|
||
|
||
if (host.startsWith("duckduckgo.")) { | ||
result = getParameterByName("q"); | ||
} | ||
|
||
if (host.startsWith("yandex.")) { | ||
if (location.pathname === "/search/touch/") { | ||
result = getParameterByName("text"); | ||
} | ||
} | ||
|
||
["baidu.", "so."].forEach(function(item){ | ||
if (host.includes(item)) { | ||
result = getParameterByName((host.includes("baidu.")) ? "oq" : "src"); | ||
} | ||
}); | ||
|
||
if (host.startsWith("sogou.")) { | ||
if (location.pathname === "/web") { | ||
result = getParameterByName("query"); | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
|
||
function getParameterByName(name, url = window.location.href) { | ||
name = name.replace(/[\[\]]/g, '\\$&'); | ||
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), | ||
results = regex.exec(url); | ||
|
||
if (!results) return null; | ||
if (!results[2]) return ''; | ||
|
||
return results[2].replace(/\+/g, ' '); | ||
} | ||
|
||
function setCookie(cname, cvalue) { | ||
const d = new Date(); | ||
d.setTime(d.getTime() + (5000)); | ||
let expires = "expires="+ d.toUTCString(); | ||
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; | ||
} | ||
|
||
function getCookie(cname) { | ||
let name = cname + "="; | ||
let decodedCookie = decodeURIComponent(document.cookie); | ||
let ca = decodedCookie.split(';'); | ||
for(let i = 0; i <ca.length; i++) { | ||
let c = ca[i]; | ||
while (c.charAt(0) == ' ') { | ||
c = c.substring(1); | ||
} | ||
if (c.indexOf(name) == 0) { | ||
return c.substring(name.length, c.length); | ||
} | ||
} | ||
return ""; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
38 changes: 38 additions & 0 deletions
38
safari/Legacy iOS/KagiForSafari Extension/Resources/manifest.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"manifest_version": 2, | ||
"default_locale": "en", | ||
|
||
"name": "__MSG_extension_name__", | ||
"description": "__MSG_extension_description__", | ||
"version": "1.0.9", | ||
|
||
"icons": { | ||
"48": "images/icon.png", | ||
"96": "images/icon.png", | ||
"128": "images/icon.png" | ||
}, | ||
|
||
"background": { | ||
"scripts": ["background.js"], | ||
"persistent": false | ||
}, | ||
|
||
"content_scripts": [{ | ||
"js": [ "content.js" ], | ||
"matches": [ "<all_urls>" ], | ||
"run_at": "document_start" | ||
}], | ||
|
||
"browser_action": { | ||
"default_popup": "popup.html", | ||
"default_icon": { | ||
"16": "images/icon.png", | ||
"19": "images/icon.png", | ||
"32": "images/icon.png", | ||
"48": "images/icon.png", | ||
"72": "images/icon.png" | ||
} | ||
}, | ||
|
||
"permissions": [ "<all_urls>", "nativeMessaging", "storage", "webNavigation" ] | ||
} |
88 changes: 88 additions & 0 deletions
88
safari/Legacy iOS/KagiForSafari Extension/Resources/popup.html
Large diffs are not rendered by default.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
safari/Legacy iOS/KagiForSafari Extension/Resources/popup.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
document.getElementById("footerLink").onclick = function() { | ||
window.open("https://kagi.com/settings?p=user_details#sessionlink"); | ||
}; | ||
|
||
chrome.storage.local.get("privateSessionLink", function(value) { | ||
var privateSessionLink = value.privateSessionLink; | ||
if (typeof(privateSessionLink) !== "undefined") { | ||
document.getElementById('privateSessionLink').value = value.privateSessionLink; | ||
} | ||
}); | ||
|
||
document.getElementById('privateSessionLink').addEventListener('input', function (evt) { | ||
chrome.storage.local.set({ privateSessionLink: document.getElementById('privateSessionLink').value}); | ||
}); |
16 changes: 16 additions & 0 deletions
16
safari/Legacy iOS/KagiForSafari Extension/SafariWebExtensionHandler.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// SafariWebExtensionHandler.swift | ||
// KagiForSafari Extension | ||
// | ||
// Created by apples on 31.01.2022. | ||
// | ||
|
||
import SafariServices | ||
import os.log | ||
|
||
class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { | ||
func beginRequest(with context: NSExtensionContext) { | ||
let response = NSExtensionItem() | ||
context.completeRequest(returningItems: [response], completionHandler: nil) | ||
} | ||
} |
Oops, something went wrong.