about summary refs log tree commit diff stats
path: root/src/assets/javascripts/frontend.js
blob: 73b864b48be0c2cfc07a1ac9516440c33eb95869 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
class FrontEnd {
	constructor({ name, redirect, frontends, protocols, enable }) {
		this.name = name
		this.redirect = redirect
		this.enable = enable
		fetch("/instances/data.json")
			.then(response => response.text())
			.then(async data => {
				const json = JSON.parse(data)
				this.frontends = {}
				for (const frontend of frontends) {
					this.frontends[frontend] = json[frontend]
					for (const protocol of json[frontend]) {
						browser.storage.local.set({
							[`${name}_${protocol}_checks`]: json[frontend][protocol],
						})
					}
				}
			})

		browser.storage.local.get(["cloudflareBlackList", "offlineBlackList"], r => {})
		this.protocols = protocols
	}
	switchInstance(url) {}
}

let Reddit = new FrontEnd({
	name: "youtube",
	redirect: function () {},
	targets: [/^https?:\/{2}(www\.|old\.|np\.|new\.|amp\.|)reddit\.com/, /^https?:\/{2}(i\.|preview\.)redd\.it/],
	frontends: ["libreddit", "teddit"],
	enable: true,
})