-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9740e0a
Showing
41 changed files
with
1,783 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 @@ | ||
Custom Search.xcodeproj/xcuserdata/ | ||
Custom Search.xcodeproj/project.xcworkspace/xcuserdata/ |
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,27 @@ | ||
# | ||
# Copyright (C) 2022 Marvin Häuser. All rights reserved. | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
|
||
--swiftversion 5.7 | ||
|
||
--maxwidth 80 | ||
|
||
--self insert | ||
|
||
--wraparguments before-first | ||
--wrapparameters before-first | ||
--wrapcollections before-first | ||
--wrapconditions before-first | ||
--wraptypealiases before-first | ||
|
||
--enable blankLineAfterImports | ||
--enable blockComments | ||
--enable isEmpty | ||
--enable wrapConditionalBodies | ||
--enable wrapEnumCases | ||
--enable wrapSwitchCases | ||
|
||
--disable redundantNilInit | ||
--disable redundantRawValues | ||
--disable redundantReturn |
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
Custom Search.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
Custom Search.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist
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 @@ | ||
<?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>IDEDidComputeMac32BitWarning</key> | ||
<true/> | ||
</dict> | ||
</plist> |
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,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (C) 2022, Marvin Häuser | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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 @@ | ||
# CustomSearch |
11 changes: 11 additions & 0 deletions
11
Shared (App)/Assets.xcassets/AccentColor.colorset/Contents.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,11 @@ | ||
{ | ||
"colors" : [ | ||
{ | ||
"idiom" : "universal" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
Shared (App)/Assets.xcassets/AppIcon.appiconset/Contents.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,63 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"platform" : "ios", | ||
"size" : "1024x1024" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "16x16" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "32x32" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "128x128" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "256x256" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "1x", | ||
"size" : "512x512" | ||
}, | ||
{ | ||
"idiom" : "mac", | ||
"scale" : "2x", | ||
"size" : "512x512" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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,6 @@ | ||
{ | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
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> |
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": "Custom Search", | ||
"description": "The display name for the extension." | ||
}, | ||
"extension_description": { | ||
"message": "This is Custom Search. You should tell us what your extension does here.", | ||
"description": "Description of what the extension does." | ||
} | ||
} |
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,67 @@ | ||
const filter = { | ||
url: | ||
[ | ||
{urlPrefix: "https://", hostEquals: "www.google.com", pathEquals: "/search", queryPrefix: "client=safari&", queryContains: "&q=", querySuffix: "&ie=UTF-8&oe=UTF-8"}, | ||
{urlPrefix: "https://", hostEquals: "search.yahoo.com", pathEquals: "/search", queryPrefix: "ei=utf-8&fr=aaplw&p="}, | ||
{urlPrefix: "https://", hostEquals: "www.bing.com", pathEquals: "/search", queryPrefix: "q=", querySuffix: "&form=APMCS1&PC=APMC"}, | ||
{urlPrefix: "https://", hostEquals: "duckduckgo.com", pathEquals: "/", queryPrefix: "q=", querySuffix: "&t=osx"}, | ||
{urlPrefix: "https://", hostEquals: "www.ecosia.org", pathEquals: "/search", queryPrefix: "q=", querySuffix: "&tts=st_asaf_macos"} | ||
], | ||
types: ["main_frame"] | ||
}; | ||
|
||
var query_url = ""; | ||
|
||
function updateQueryUrl(url) { | ||
query_url = url || ""; | ||
|
||
if (query_url === "") { | ||
browser.declarativeNetRequest.updateEnabledRulesets( | ||
{ disableRulesetIds: [ "block_search" ] } | ||
) | ||
} else { | ||
browser.declarativeNetRequest.updateEnabledRulesets( | ||
{ enableRulesetIds: [ "block_search" ] } | ||
) | ||
} | ||
}; | ||
|
||
function readSettings() { | ||
function cacheSettings(result) { | ||
updateQueryUrl(result.query_url) | ||
}; | ||
|
||
function onError(error) { | ||
console.log(`Error: ${error}`); | ||
}; | ||
|
||
let getting = browser.storage.sync.get("query_url"); | ||
getting.then(cacheSettings, onError); | ||
}; | ||
|
||
function settingsChanged(changes) { | ||
if (Object.keys(changes).includes("query_url")) { | ||
updateQueryUrl(changes["query_url"].newValue) | ||
} | ||
}; | ||
|
||
function before(details) { | ||
if (query_url === "") { | ||
return | ||
} | ||
|
||
const url = new URL(details.url); | ||
|
||
var queryKey = "q"; | ||
if (url.hostname === "search.yahoo.com") { | ||
queryKey = "p"; | ||
} | ||
|
||
const query = encodeURIComponent(url.searchParams.get(queryKey)); | ||
browser.tabs.update(details.tabId, { url: query_url + query }); | ||
}; | ||
|
||
browser.storage.sync.onChanged.addListener(settingsChanged) | ||
readSettings() | ||
|
||
browser.webNavigation.onBeforeNavigate.addListener(before, filter); |
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,47 @@ | ||
[ | ||
{ | ||
"id": 1, | ||
"priority": 1, | ||
"action": { "type": "block" }, | ||
"condition": { | ||
"urlFilter": "|https://www.google.com/search?client=safari&*&q=*&ie=UTF-8&oe=UTF-8|", | ||
"resourceTypes": [ "main_frame" ] | ||
} | ||
}, | ||
{ | ||
"id": 2, | ||
"priority": 1, | ||
"action": { "type": "block" }, | ||
"condition": { | ||
"urlFilter": "|https://search.yahoo.com/search?ei=utf-8&fr=aaplw&p=*", | ||
"resourceTypes": [ "main_frame" ] | ||
} | ||
}, | ||
{ | ||
"id": 3, | ||
"priority": 1, | ||
"action": { "type": "block" }, | ||
"condition": { | ||
"urlFilter": "|https://www.bing.com/search?q=*&form=APMCS1&PC=APMC|", | ||
"resourceTypes": [ "main_frame" ] | ||
} | ||
}, | ||
{ | ||
"id": 4, | ||
"priority": 1, | ||
"action": { "type": "block" }, | ||
"condition": { | ||
"urlFilter": "|https://duckduckgo.com/?q=*&t=osx|", | ||
"resourceTypes": [ "main_frame" ] | ||
} | ||
}, | ||
{ | ||
"id": 5, | ||
"priority": 1, | ||
"action": { "type": "block" }, | ||
"condition": { | ||
"urlFilter": "|https://www.ecosia.org/search?q=*&tts=st_asaf_macos|", | ||
"resourceTypes": [ "main_frame" ] | ||
} | ||
} | ||
] |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,46 @@ | ||
{ | ||
"manifest_version": 3, | ||
"default_locale": "en", | ||
|
||
"name": "__MSG_extension_name__", | ||
"description": "__MSG_extension_description__", | ||
"version": "1.0", | ||
|
||
"icons": { | ||
"48": "images/icon-48.png", | ||
"96": "images/icon-96.png", | ||
"128": "images/icon-128.png", | ||
"256": "images/icon-256.png", | ||
"512": "images/icon-512.png" | ||
}, | ||
|
||
"background": { | ||
"service_worker": "background.js" | ||
}, | ||
|
||
"action": { | ||
"default_popup": "popup.html", | ||
"default_icon": { | ||
"16": "images/toolbar-icon-16.png", | ||
"19": "images/toolbar-icon-19.png", | ||
"32": "images/toolbar-icon-32.png", | ||
"38": "images/toolbar-icon-38.png", | ||
"48": "images/toolbar-icon-48.png", | ||
"72": "images/toolbar-icon-72.png" | ||
} | ||
}, | ||
|
||
"declarative_net_request" : { | ||
"rule_resources" : [{ | ||
"id": "block_search", | ||
"enabled": true, | ||
"path": "block_search.json" | ||
}] | ||
}, | ||
|
||
"permissions": [ | ||
"webNavigation", | ||
"storage", | ||
"declarativeNetRequest" | ||
] | ||
} |
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 @@ | ||
:root { | ||
color-scheme: light dark; | ||
} | ||
|
||
body { | ||
padding: 10px; | ||
|
||
font-family: system-ui; | ||
text-align: center; | ||
} | ||
|
||
@media (prefers-color-scheme: dark) { | ||
/* Dark Mode styles go here. */ | ||
} |
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 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<link rel="stylesheet" href="popup.css"> | ||
<script type="module" src="popup.js"></script> | ||
</head> | ||
<body> | ||
<strong>Custom Search</strong><br><br> | ||
<label for="query_url">Search Engine URL prefix:</label><br><br> | ||
<form> | ||
<input type="text" id="query_url" name="query_url" size="40"><br><br> | ||
<input type="submit" value="Save"> | ||
</form> | ||
</body> | ||
</html> |
Oops, something went wrong.