diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..13566b81
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Editor-based HTTP Client requests
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml
diff --git a/.idea/SteamOS-Plugin-Manager.iml b/.idea/SteamOS-Plugin-Manager.iml
new file mode 100644
index 00000000..c254557e
--- /dev/null
+++ b/.idea/SteamOS-Plugin-Manager.iml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..8875d58a
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main.rs b/src/main.rs
index 90d23a26..6d35cdf2 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,5 @@
use std::fmt::{Debug, Display, Formatter};
+use std::fs;
use hyper::{Client, Uri};
use hyper::body::Buf;
use serde::{ Serialize, Deserialize };
@@ -72,6 +73,30 @@ async fn get_web_content(url: Uri) -> TokioResult> {
Ok(serde_json::from_str(data.as_str())?)
}
+fn load_plugins() -> String {
+ let paths = fs::read_dir("./plugins");
+ if let Ok(paths) = paths {
+
+ let mut result = String::new();
+
+ for entry in paths {
+ if let Ok(entry) = entry {
+ if let Ok(file_type) = entry.file_type() {
+ if file_type.is_file() {
+ if let Ok(content) = fs::read_to_string(entry.path()) {
+ result.push_str(format!("plugins.push(new {});", content).as_str());
+ }
+ }
+ }
+ }
+ }
+
+ result
+ } else {
+ String::from("")
+ }
+}
+
#[tokio::main]
async fn main() -> TokioResult<()> {
let url = "http://127.0.0.1:8080/json".parse::().unwrap();
@@ -98,7 +123,7 @@ async fn main() -> TokioResult<()> {
id: 1,
method: String::from("Runtime.evaluate"),
params: DebuggerCommandParams {
- expression: String::from(include_str!("plugin_page.js")),
+ expression: String::from(include_str!("plugin_page.js").replace("{{ PLUGINS }}", load_plugins().as_str())),
userGesture: true
}
};
diff --git a/src/plugin_page.js b/src/plugin_page.js
index 50dc419c..537f53a3 100644
--- a/src/plugin_page.js
+++ b/src/plugin_page.js
@@ -1,4 +1,8 @@
(function () {
+ let plugins = [];
+
+ {{ PLUGINS }}
+
const PLUGIN_ICON = `