summaryrefslogtreecommitdiff
path: root/backend/utilities.py
diff options
context:
space:
mode:
authorJonas Dellinger <jonas@dellinger.dev>2022-05-31 18:05:26 +0200
committerJonas Dellinger <jonas@dellinger.dev>2022-05-31 18:05:26 +0200
commitbd1b2e82fdc6ff1725bab61593e1f54d0b975fe0 (patch)
treedb0e867be4088ff226f8b9a9cd5d1e01bec5ba0e /backend/utilities.py
parent660e34664ee749f59e43620e541c72fd21a2284a (diff)
downloaddecky-loader-bd1b2e82fdc6ff1725bab61593e1f54d0b975fe0.tar.gz
decky-loader-bd1b2e82fdc6ff1725bab61593e1f54d0b975fe0.zip
Move store opening to frontend only
Diffstat (limited to 'backend/utilities.py')
-rw-r--r--backend/utilities.py35
1 files changed, 12 insertions, 23 deletions
diff --git a/backend/utilities.py b/backend/utilities.py
index 983bb790..d69b9bfa 100644
--- a/backend/utilities.py
+++ b/backend/utilities.py
@@ -1,7 +1,10 @@
+import uuid
+from json.decoder import JSONDecodeError
+
from aiohttp import ClientSession, web
+
from injector import inject_to_tab
-from json.decoder import JSONDecodeError
-import uuid
+
class Utilities:
def __init__(self, context) -> None:
@@ -12,8 +15,7 @@ class Utilities:
"confirm_plugin_install": self.confirm_plugin_install,
"execute_in_tab": self.execute_in_tab,
"inject_css_into_tab": self.inject_css_into_tab,
- "remove_css_from_tab": self.remove_css_from_tab,
- "open_plugin_store": self.open_plugin_store
+ "remove_css_from_tab": self.remove_css_from_tab
}
if context:
@@ -53,7 +55,7 @@ class Utilities:
async def ping(self, **kwargs):
return "pong"
- async def execute_in_tab(self, tab, run_async, code):
+ async def execute_in_tab(self, tab, run_async, code):
try:
result = await inject_to_tab(tab, code, run_async)
if "exceptionDetails" in result["result"]:
@@ -67,7 +69,7 @@ class Utilities:
"result" : result["result"]["result"].get("value")
}
except Exception as e:
- return {
+ return {
"success": False,
"result": e
}
@@ -76,7 +78,7 @@ class Utilities:
try:
css_id = str(uuid.uuid4())
- result = await inject_to_tab(tab,
+ result = await inject_to_tab(tab,
f"""
(function() {{
const style = document.createElement('style');
@@ -97,14 +99,14 @@ class Utilities:
"result" : css_id
}
except Exception as e:
- return {
+ return {
"success": False,
"result": e
}
async def remove_css_from_tab(self, tab, css_id):
try:
- result = await inject_to_tab(tab,
+ result = await inject_to_tab(tab,
f"""
(function() {{
let style = document.getElementById("{css_id}");
@@ -124,20 +126,7 @@ class Utilities:
"success": True
}
except Exception as e:
- return {
+ return {
"success": False,
"result": e
}
-
- async def open_plugin_store(self):
- await inject_to_tab("SP", """
- (function() {
- wpRequire = webpackJsonp.push([[], { get_require: (mod, _exports, wpRequire) => mod.exports = wpRequire }, [["get_require"]]]);
- const all = () => Object.keys(wpRequire.c).map((x) => wpRequire.c[x].exports).filter((x) => x);
- router = all().map(m => {
- if (typeof m !== "object") return undefined;
- for (let prop in m) { if (m[prop]?.Navigate) return m[prop]}
- }).find(x => x)
- router.NavigateToExternalWeb("http://127.0.0.1:1337/browser/redirect")
- })();
- """) \ No newline at end of file