Skip to content

Commit

Permalink
1.1.1 => 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ManeraKai committed Jul 14, 2023
1 parent efae11b commit d36181e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 82 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@ An extension that redirects you to your favorite instannce.
</a>

It currently supports:
- [Lemmy](https://join-lemmy.org) => [Lemmy](https://join-lemmy.org)
- [Mastodon](https://joinmastodon.org) => [Mastodon](https://joinmastodon.org)
- [Mastodon](https://joinmastodon.org) => [Lemmy](https://join-lemmy.org/)
- [Lemmy](https://join-lemmy.org/) => [Mastodon](https://joinmastodon.org)
- [Mastodon](https://joinmastodon.org)
- [Soapbox](https://soapbox.pub)
- [Lemmy](https://join-lemmy.org)


## Demo:
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"version": "1.1.1",
"version": "1.2.0",
"manifest_version": 2,
"browser_specific_settings": {
"gecko": {
Expand Down
77 changes: 0 additions & 77 deletions src/pages/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
window.browser = window.browser || window.chrome

function getRandomInstance(instances) {
return instances[~~(instances.length * Math.random())]
}

function camelCase(str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}

function protocolHost(url) {
url = new URL(url)
if (url.username && url.password) return `${url.protocol}//${url.username}:${url.password}@${url.host}`
Expand All @@ -27,78 +19,9 @@ function isMyInstance(url, software) {
return url.hostname == instance.hostname
}

function getBlacklist(options) {
return new Promise(resolve => {
let url
if (options.fetchInstances == 'github') {
url = 'https://raw.githubusercontent.com/libredirect/instances/main/blacklist.json'
}
else if (options.fetchInstances == 'codeberg') {
url = 'https://codeberg.org/LibRedirect/instances/raw/branch/main/blacklist.json'
}
else {
resolve('disabled')
return
}
const http = new XMLHttpRequest()
http.open("GET", url, true)
http.onreadystatechange = () => {
if (http.status === 200 && http.readyState == XMLHttpRequest.DONE) {
resolve(JSON.parse(http.responseText))
return
}
}
http.onerror = () => {
resolve()
return
}
http.ontimeout = () => {
resolve()
return
}
http.send(null)
})
}

function getList(options) {
return new Promise(resolve => {
let url
if (options.fetchInstances == 'github') {
url = 'https://raw.githubusercontent.com/libredirect/instances/main/data.json'
}
else if (options.fetchInstances == 'codeberg') {
url = 'https://codeberg.org/LibRedirect/instances/raw/branch/main/data.json'
}
else {
resolve('disabled')
return
}
const http = new XMLHttpRequest()
http.open("GET", url, true)
http.onreadystatechange = () => {
if (http.status === 200 && http.readyState == XMLHttpRequest.DONE) {
resolve(JSON.parse(http.responseText))
return
}
}
http.onerror = () => {
resolve()
return
}
http.ontimeout = () => {
resolve()
return
}
http.send(null)
})
}

export default {
getRandomInstance,
protocolHost,
getList,
getBlacklist,
camelCase,
getOptions,
isMyInstance
}

0 comments on commit d36181e

Please sign in to comment.