documentation

This commit is contained in:
vel 2022-01-30 18:25:54 -08:00
parent 11b73b13ea
commit 4e6d5f4c6b
Signed by: velvox
GPG Key ID: 1C8200C1D689CEF5
4 changed files with 1437 additions and 1029 deletions

View File

@ -1,63 +1,68 @@
import { import { t } from "./index-6137f488.js";
t import { s, m } from "./storage-a8ac7bd3.js";
} from './index-6137f488.js'; import { n } from "./connectRuntime-a699491c.js";
import {
s,
m
} from './storage-a8ac7bd3.js';
import {
n
} from './connectRuntime-a699491c.js';
class o extends t { class o extends t {
constructor() { constructor() {
super(), this.fetch = async (t, e) => { super();
const s = Math.random().toString(); this.fetch = async (t, e) => {
return this.port.postMessage({ const s = Math.random().toString();
nonce: s, return (
path: t, this.port.postMessage({
body: e nonce: s,
}), new Promise((t => { path: t,
const e = a => { body: e,
a.meta.nonce === s && (this.port.onMessage.removeListener(e), t(a)); }),
}; new Promise((t) => {
this.port.onMessage.addListener(e); const e = (a) => {
})) a.meta.nonce === s && (this.port.onMessage.removeListener(e), t(a));
}, this.extensionId = s.runtime.id, this.port = this.connectToBackground(), this.port.onMessage.addListener(this.onMessage), window.addEventListener("message", (async t => { };
var e, a, o; this.port.onMessage.addListener(e);
if (t.source !== window || (null === (e = t.data) || void 0 === e ? void 0 : e.id) !== this.extensionId || "response" === (null === (a = t.data) || void 0 === a ? void 0 : a.type)) return; })
let n; );
switch (null === (o = t.data) || void 0 === o ? void 0 : o.type) { };
case "fetch": this.extensionId = s.runtime.id;
n = await this.fetch(t.data.data[0], t.data.data[1]); this.port = this.connectToBackground();
break; this.port.onMessage.addListener(this.onMessage);
case "storage.get": { window.addEventListener("message", async (t) => {
const [e, a] = t.data.data.split("."); var e, a, o;
n = await m[e].get(a); if (
break t.source !== window ||
} (null === (e = t.data) || void 0 === e ? void 0 : e.id) !==
case "storage.set": { this.extensionId ||
const [e, a] = t.data.data[0].split("."); "response" === (null === (a = t.data) || void 0 === a ? void 0 : a.type)
n = await m[e].set(a, t.data.data[1]); )
break return;
} let n;
} switch (null === (o = t.data) || void 0 === o ? void 0 : o.type) {
window.postMessage({ case "fetch":
id: this.extensionId, n = await this.fetch(t.data.data[0], t.data.data[1]);
nonce: t.data.nonce, break;
type: "response", case "storage.get": {
data: n const [e, a] = t.data.data.split(".");
}); n = await m[e].get(a);
})); break;
} }
connectToBackground() { case "storage.set": {
return n() const [e, a] = t.data.data[0].split(".");
} n = await m[e].set(a, t.data.data[1]);
async onMessage(t) { break;
window.postMessage(t); }
} }
window.postMessage({
id: this.extensionId,
nonce: t.data.nonce,
type: "response",
data: n,
});
});
}
connectToBackground() {
return n();
}
async onMessage(t) {
window.postMessage(t);
}
} }
export { export { o };
o
};

View File

@ -1,52 +1,69 @@
import { import { t } from "./index-6137f488.js";
t
} from './index-6137f488.js';
class e extends t { class e extends t {
constructor() { constructor() {
super(), this.fetch = async (t, e) => this.sendToContentScript("fetch", [t, e]), this.extensionId = function() { super();
var t; this.fetch = async (t, e) => this.sendToContentScript("fetch", [t, e]);
const e = null === (t = document.getElementById("XQpBuigyZWZGIjvE")) || void 0 === t ? void 0 : t.getAttribute("XQpBuigyZWZGIjvE"); this.extensionId = (function () {
if (!e) throw new Error("Could not resolve extension ID from injected script"); var t;
return e const e =
}(), window.addEventListener("message", (t => { null === (t = document.getElementById("XQpBuigyZWZGIjvE")) ||
var e, n; void 0 === t
t.source === window && (null === (e = t.data) || void 0 === e ? void 0 : e.id) === this.extensionId && "event" === (null === (n = t.data) || void 0 === n ? void 0 : n.type) && this.onMessage(t.data.data); ? void 0
})); : t.getAttribute("XQpBuigyZWZGIjvE");
} if (!e)
async onMessage(t) {} throw new Error("Could not resolve extension ID from injected script");
async getStorage(t) { return e;
return await this.sendToContentScript("storage.get", t) })();
} window.addEventListener("message", (t) => {
async getLiveStorageValue(t, e = (t => t)) { var e, n;
const n = { t.source === window &&
value: e(await this.getStorage(t)) (null === (e = t.data) || void 0 === e ? void 0 : e.id) ===
}, this.extensionId &&
o = window.setInterval((async () => { "event" === (null === (n = t.data) || void 0 === n ? void 0 : n.type) &&
n.value = e(await this.getStorage(t)); this.onMessage(t.data.data);
}), 1e3); });
return n.interval = o, n }
} async onMessage(t) {}
async setStorage(t, e) { async getStorage(t) {
return this.sendToContentScript("storage.set", [t, e]) return await this.sendToContentScript("storage.get", t);
} }
async sendToContentScript(t, e) { async getLiveStorageValue(t, e = (t) => t) {
const n = Math.random().toString(); const n = {
return window.postMessage({ value: e(await this.getStorage(t)),
id: this.extensionId, },
nonce: n, o = window.setInterval(async () => {
type: t, n.value = e(await this.getStorage(t));
data: e }, 1e3);
}), new Promise((t => { return (n.interval = o), n;
const e = o => { }
var s, a, i; async setStorage(t, e) {
o.source === window && (null === (s = o.data) || void 0 === s ? void 0 : s.id) === this.extensionId && (null === (a = o.data) || void 0 === a ? void 0 : a.nonce) === n && "response" === (null === (i = o.data) || void 0 === i ? void 0 : i.type) && (t(o.data.data), window.removeEventListener("message", e)); return this.sendToContentScript("storage.set", [t, e]);
}; }
window.addEventListener("message", e); async sendToContentScript(t, e) {
})) const n = Math.random().toString();
} return (
window.postMessage({
id: this.extensionId,
nonce: n,
type: t,
data: e,
}),
new Promise((t) => {
const e = (o) => {
var s, a, i;
o.source === window &&
(null === (s = o.data) || void 0 === s ? void 0 : s.id) ===
this.extensionId &&
(null === (a = o.data) || void 0 === a ? void 0 : a.nonce) === n &&
"response" ===
(null === (i = o.data) || void 0 === i ? void 0 : i.type) &&
(t(o.data.data), window.removeEventListener("message", e));
};
window.addEventListener("message", e);
})
);
}
} }
export { export { e };
e
};

File diff suppressed because it is too large Load Diff

View File

@ -1,113 +1,152 @@
var e = { var e = {
exports: {} exports: {},
}; };
! function(e) { !(function (e) {
var t = Object.prototype.hasOwnProperty, var t = Object.prototype.hasOwnProperty,
n = "~"; n = "~";
function r() {} function r() {}
function o(e, t, n) { function o(e, t, n) {
this.fn = e, this.context = t, this.once = n || !1; (this.fn = e), (this.context = t), (this.once = n || !1);
} }
function s(e, t, r, s, i) { function s(e, t, r, s, i) {
if ("function" != typeof r) throw new TypeError("The listener must be a function"); if ("function" != typeof r)
var c = new o(r, s || e, i), throw new TypeError("The listener must be a function");
f = n ? n + t : t; var c = new o(r, s || e, i),
return e._events[f] ? e._events[f].fn ? e._events[f] = [e._events[f], c] : e._events[f].push(c) : (e._events[f] = c, e._eventsCount++), e f = n ? n + t : t;
} return (
e._events[f]
? e._events[f].fn
? (e._events[f] = [e._events[f], c])
: e._events[f].push(c)
: ((e._events[f] = c), e._eventsCount++),
e
);
}
function i(e, t) { function i(e, t) {
0 == --e._eventsCount ? e._events = new r : delete e._events[t]; 0 == --e._eventsCount ? (e._events = new r()) : delete e._events[t];
} }
function c() { function c() {
this._events = new r, this._eventsCount = 0; (this._events = new r()), (this._eventsCount = 0);
} }
Object.create && (r.prototype = Object.create(null), (new r).__proto__ || (n = !1)), c.prototype.eventNames = function() { Object.create &&
var e, r, o = []; ((r.prototype = Object.create(null)), new r().__proto__ || (n = !1)),
if (0 === this._eventsCount) return o; (c.prototype.eventNames = function () {
for (r in e = this._events) t.call(e, r) && o.push(n ? r.slice(1) : r); var e,
return Object.getOwnPropertySymbols ? o.concat(Object.getOwnPropertySymbols(e)) : o r,
}, c.prototype.listeners = function(e) { o = [];
var t = n ? n + e : e, if (0 === this._eventsCount) return o;
r = this._events[t]; for (r in (e = this._events)) t.call(e, r) && o.push(n ? r.slice(1) : r);
if (!r) return []; return Object.getOwnPropertySymbols
if (r.fn) return [r.fn]; ? o.concat(Object.getOwnPropertySymbols(e))
for (var o = 0, s = r.length, i = new Array(s); o < s; o++) i[o] = r[o].fn; : o;
return i }),
}, c.prototype.listenerCount = function(e) { (c.prototype.listeners = function (e) {
var t = n ? n + e : e, var t = n ? n + e : e,
r = this._events[t]; r = this._events[t];
return r ? r.fn ? 1 : r.length : 0 if (!r) return [];
}, c.prototype.emit = function(e, t, r, o, s, i) { if (r.fn) return [r.fn];
var c = n ? n + e : e; for (var o = 0, s = r.length, i = new Array(s); o < s; o++)
if (!this._events[c]) return !1; i[o] = r[o].fn;
var f, a, u = this._events[c], return i;
v = arguments.length; }),
if (u.fn) { (c.prototype.listenerCount = function (e) {
switch (u.once && this.removeListener(e, u.fn, void 0, !0), v) { var t = n ? n + e : e,
case 1: r = this._events[t];
return u.fn.call(u.context), !0; return r ? (r.fn ? 1 : r.length) : 0;
case 2: }),
return u.fn.call(u.context, t), !0; (c.prototype.emit = function (e, t, r, o, s, i) {
case 3: var c = n ? n + e : e;
return u.fn.call(u.context, t, r), !0; if (!this._events[c]) return !1;
case 4: var f,
return u.fn.call(u.context, t, r, o), !0; a,
case 5: u = this._events[c],
return u.fn.call(u.context, t, r, o, s), !0; v = arguments.length;
case 6: if (u.fn) {
return u.fn.call(u.context, t, r, o, s, i), !0 switch ((u.once && this.removeListener(e, u.fn, void 0, !0), v)) {
} case 1:
for (a = 1, f = new Array(v - 1); a < v; a++) f[a - 1] = arguments[a]; return u.fn.call(u.context), !0;
u.fn.apply(u.context, f); case 2:
} else { return u.fn.call(u.context, t), !0;
var p, l = u.length; case 3:
for (a = 0; a < l; a++) switch (u[a].once && this.removeListener(e, u[a].fn, void 0, !0), v) { return u.fn.call(u.context, t, r), !0;
case 1: case 4:
u[a].fn.call(u[a].context); return u.fn.call(u.context, t, r, o), !0;
break; case 5:
case 2: return u.fn.call(u.context, t, r, o, s), !0;
u[a].fn.call(u[a].context, t); case 6:
break; return u.fn.call(u.context, t, r, o, s, i), !0;
case 3:
u[a].fn.call(u[a].context, t, r);
break;
case 4:
u[a].fn.call(u[a].context, t, r, o);
break;
default:
if (!f)
for (p = 1, f = new Array(v - 1); p < v; p++) f[p - 1] = arguments[p];
u[a].fn.apply(u[a].context, f);
}
} }
return !0 for (a = 1, f = new Array(v - 1); a < v; a++) f[a - 1] = arguments[a];
}, c.prototype.on = function(e, t, n) { u.fn.apply(u.context, f);
return s(this, e, t, n, !1) } else {
}, c.prototype.once = function(e, t, n) { var p,
return s(this, e, t, n, !0) l = u.length;
}, c.prototype.removeListener = function(e, t, r, o) { for (a = 0; a < l; a++)
var s = n ? n + e : e; switch (
if (!this._events[s]) return this; (u[a].once && this.removeListener(e, u[a].fn, void 0, !0), v)
if (!t) return i(this, s), this; ) {
var c = this._events[s]; case 1:
if (c.fn) c.fn !== t || o && !c.once || r && c.context !== r || i(this, s); u[a].fn.call(u[a].context);
else { break;
for (var f = 0, a = [], u = c.length; f < u; f++)(c[f].fn !== t || o && !c[f].once || r && c[f].context !== r) && a.push(c[f]); case 2:
a.length ? this._events[s] = 1 === a.length ? a[0] : a : i(this, s); u[a].fn.call(u[a].context, t);
} break;
return this case 3:
}, c.prototype.removeAllListeners = function(e) { u[a].fn.call(u[a].context, t, r);
var t; break;
return e ? (t = n ? n + e : e, this._events[t] && i(this, t)) : (this._events = new r, this._eventsCount = 0), this case 4:
}, c.prototype.off = c.prototype.removeListener, c.prototype.addListener = c.prototype.on, c.prefixed = n, c.EventEmitter = c, e.exports = c; u[a].fn.call(u[a].context, t, r, o);
}(e); break;
default:
if (!f)
for (p = 1, f = new Array(v - 1); p < v; p++)
f[p - 1] = arguments[p];
u[a].fn.apply(u[a].context, f);
}
}
return !0;
}),
(c.prototype.on = function (e, t, n) {
return s(this, e, t, n, !1);
}),
(c.prototype.once = function (e, t, n) {
return s(this, e, t, n, !0);
}),
(c.prototype.removeListener = function (e, t, r, o) {
var s = n ? n + e : e;
if (!this._events[s]) return this;
if (!t) return i(this, s), this;
var c = this._events[s];
if (c.fn)
c.fn !== t || (o && !c.once) || (r && c.context !== r) || i(this, s);
else {
for (var f = 0, a = [], u = c.length; f < u; f++)
(c[f].fn !== t || (o && !c[f].once) || (r && c[f].context !== r)) &&
a.push(c[f]);
a.length ? (this._events[s] = 1 === a.length ? a[0] : a) : i(this, s);
}
return this;
}),
(c.prototype.removeAllListeners = function (e) {
var t;
return (
e
? ((t = n ? n + e : e), this._events[t] && i(this, t))
: ((this._events = new r()), (this._eventsCount = 0)),
this
);
}),
(c.prototype.off = c.prototype.removeListener),
(c.prototype.addListener = c.prototype.on),
(c.prefixed = n),
(c.EventEmitter = c),
(e.exports = c);
})(e);
var t = e.exports; var t = e.exports;
export { export { e, t };
e,
t
};