-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(plugin): add file to consolidate chrome/firefox APIs (#401)
* refactor(plugin): add file to consolidate chrome/firefox APIs At 2-3 places in the codebase, we're checking if the browser is chrome or firefox, and hen using the corresponding APIs chrome.* or browser.* respectively. To reduce code repetition this adds a file browser-compat.js that exposes objects corresponding to various browser APIs such that they can be used by other functions in a browser agnostic way. --------- Co-authored-by: Aatman Vaidya <[email protected]>
- Loading branch information
1 parent
db1ec1e
commit e83d90e
Showing
7 changed files
with
105 additions
and
94 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 |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
<a href="mailto:[email protected]">Email</a><br/><br/> | ||
<a href="https://uli.tattle.co.in/">Website</a> | | ||
<a href="https://uli.tattle.co.in/user-guide">User Guide</a> | | ||
<a href="https://godoc.org/github.com/ory/hydra">Blog</a><br/><br/> | ||
<a href="https://uli.tattle.co.in/blog">Blog</a><br/><br/> | ||
<a href="https://github.com/tattle-made/Uli/blob/main/browser-extension/plugin/scripts/slur-list.txt">Uli Slur List licensed under ODBL</a><br/><br/> | ||
</h4> | ||
|
||
|
@@ -25,13 +25,12 @@ Uli is a browser plugin that : | |
|
||
It is an attempt to invert the top-down logics of platform moderation and center the experiences of those subject to online gender-based violence. | ||
|
||
|
||
<h1 align="center">🎉 We're participating in Hacktoberfest 2023! 🎉</h1> | ||
<h1 align="center">🎉 Contribution Pathways 🎉</h1> | ||
We cherish diversity of experiences and perspectives. It adds value to our work. To this end, we strongly encourage candidates who find alignment with the project and are driven to learn, to contribute to Uli. There are both code and no-code issues that you can contribute to. | ||
|
||
To contribute effectively, we recommend doing some of these: | ||
- Peruse our [Wiki](https://github.com/tattle-made/Uli/wiki). It will help you navigate our repository, and adhere to our standards for contributions. | ||
- We've labeled beginner frienly issues with [hacktoberfest](https://github.com/tattle-made/Uli/labels/hacktoberfest) and [good first issue](https://github.com/tattle-made/Uli/labels/good%20first%20issue). | ||
- We've labeled beginner frienly issues with [good first issue](https://github.com/tattle-made/Uli/labels/good%20first%20issue). | ||
- Read our `Setup Guides` on the [Uli Wiki](https://github.com/tattle-made/Uli/wiki#setup-guides) or watch a [video tutorial](https://www.youtube.com/watch?v=ya2NvjtUlVI) | ||
- Join the our [Slack](https://join.slack.com/t/tattle-workspace/shared_invite/zt-24g9vngdc-VEGSv4y1OnLZ~nrvBXl6hQ) to interact with the team and get any clarificatios. | ||
Introduce yourself in the `#introductions` channel and feel free to discuss any Hacktoberfest-related questions in the `#issue_uli_hacktoberfest` channel. | ||
|
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
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,48 @@ | ||
/** | ||
* The use of this module is to expose a set of functions to access various browser | ||
* APIs commonly used in extensions. We can determine here which browser is our extension | ||
* running on and then export the corresponding browser API functions under common function | ||
* names, such that the callers of these functions can use these them in a browser-agnostic | ||
* way without having to make a browser check themselves. | ||
*/ | ||
|
||
const BROWSER_CHROME = 'chrome'; | ||
const BROWSER_FIREFOX = 'firefox'; | ||
const BROWSER_UNSUPPORTED = 'unsupported'; | ||
|
||
let userBrowser; | ||
|
||
const userAgent = window.navigator.userAgent.toLowerCase(); | ||
if (userAgent.includes('chrome')) { | ||
userBrowser = BROWSER_CHROME; | ||
} else if (userAgent.includes('firefox')) { | ||
userBrowser = BROWSER_FIREFOX; | ||
} else { | ||
userBrowser = BROWSER_UNSUPPORTED; | ||
} | ||
|
||
let userBrowserTabs; | ||
let userBrowserContextMenus; | ||
let userBrowserStorage; | ||
|
||
if (userBrowser === BROWSER_FIREFOX) { | ||
userBrowserTabs = browser.tabs; | ||
userBrowserContextMenus = browser.contextMenus; | ||
userBrowserStorage = browser.storage; | ||
} else if (userBrowser === BROWSER_CHROME) { | ||
userBrowserTabs = chrome.tabs; | ||
userBrowserContextMenus = chrome.contextMenus; | ||
userBrowserStorage = chrome.storage; | ||
} else { | ||
// TODO: Indicate to user that browser is unsupported | ||
} | ||
|
||
export { | ||
BROWSER_CHROME, | ||
BROWSER_FIREFOX, | ||
BROWSER_UNSUPPORTED, | ||
userBrowser, | ||
userBrowserTabs, | ||
userBrowserContextMenus, | ||
userBrowserStorage | ||
}; |
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
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
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
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