@delta-comic/plugin 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1048,6 +1048,14 @@ async function readFile(e, t) {
1048
1048
  });
1049
1049
  return n instanceof ArrayBuffer ? new Uint8Array(n) : Uint8Array.from(n);
1050
1050
  }
1051
+ async function readTextFile(e, t) {
1052
+ if (e instanceof URL && e.protocol !== "file:") throw TypeError("Must be a file URL.");
1053
+ let n = await invoke("plugin:fs|read_text_file", {
1054
+ path: e instanceof URL ? e.toString() : e,
1055
+ options: t
1056
+ }), r = n instanceof ArrayBuffer ? n : Uint8Array.from(n);
1057
+ return new TextDecoder().decode(r);
1058
+ }
1051
1059
  async function remove(e, t) {
1052
1060
  if (e instanceof URL && e.protocol !== "file:") throw TypeError("Must be a file URL.");
1053
1061
  await invoke("plugin:fs|remove", {
@@ -3128,22 +3136,12 @@ var Octokit = Octokit$1.plugin(requestLog, legacyRestEndpointMethods, paginateRe
3128
3136
  return e.name.endsWith(".js");
3129
3137
  }
3130
3138
  async load(e) {
3131
- let t = await readFile(await join(await getPluginFsPath(e.pluginName), "us.js"));
3132
- if (t.includes(0)) {
3133
- let e = new Uint8Array(t.length), r = 0;
3134
- for (let n = 0; n < t.length; n++) {
3135
- let i = t[n];
3136
- i !== 0 && (e[r++] = i);
3137
- }
3138
- let i = e.subarray(0, r);
3139
- var n = new Blob([i], { type: "text/javascript" });
3140
- } else var n = new Blob([t], { type: "text/javascript" });
3141
- let r = URL.createObjectURL(n), i = document.createElement("script");
3142
- i.addEventListener("load", () => {
3143
- URL.revokeObjectURL(r);
3144
- }), i.addEventListener("error", (e) => {
3145
- throw URL.revokeObjectURL(r), e;
3146
- }), i.async = !0, i.src = r, document.body.appendChild(i);
3139
+ let t = await readTextFile(await join(await getPluginFsPath(e.pluginName), "us.js")), n = t.lastIndexOf(";") + 1, r = new Blob([t.slice(0, n)], { type: "text/javascript" }), i = URL.createObjectURL(r), a = document.createElement("script");
3140
+ a.addEventListener("load", () => {
3141
+ URL.revokeObjectURL(i);
3142
+ }), a.addEventListener("error", (e) => {
3143
+ throw URL.revokeObjectURL(i), e;
3144
+ }), a.async = !0, a.src = i, document.body.appendChild(a);
3147
3145
  }
3148
3146
  }(), import_jszip_min = (/* @__PURE__ */ __commonJSMin(((e, t) => {
3149
3147
  (function(n) {