From dff83e9593faf956a097d5682f0d4fbd8248ee4f Mon Sep 17 00:00:00 2001
From: Recolic K <bensl@microsoft.com>
Date: Thu, 20 Jan 2022 18:00:05 +0800
Subject: [PATCH] finish download part

---
 README.md                |  2 +-
 downloader/README.md     |  2 ++
 downloader/background.js | 33 +++++++++++++++++++++++++++++++++
 downloader/manifest.json | 11 +++++++----
 uploader/manifest.json   |  2 +-
 5 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/README.md b/README.md
index a34334a..b5c30f1 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,6 @@ This project is a patched SimpleModifyHeader extension, which automatically sync
 
 1. Put pastebin.php on your website, and update all links to `recolic.net` in code with yours. (`grep -F recolic.net -r .`)
 2. Install `uploader` extension in windows-chrome (or edge), and install `downloader` extension in your devbox. 
-3. `Start` the extension in windows-chrome. On your devbox, use `pull|https://recolic.net/your/pastebin.php` as your "Header Field Value". 
+3. `Start` the extension in windows-chrome. On your devbox, use `pull!https://recolic.net/your/pastebin.php` as your "Header Field Value". 
 
 
diff --git a/downloader/README.md b/downloader/README.md
index 0de56ed..602154a 100644
--- a/downloader/README.md
+++ b/downloader/README.md
@@ -2,6 +2,8 @@
 
 Snapshot version git-2a4fb159e8f7c87bab2b0fd96ce0e505dc84e036
 
+patched by recolic to allow downloading header.value from internet. Search for `recolic-fkms` to see all modifications to original code. 
+
 # SimpleModifyHeaders V 1.7.0
 
 Extension for Firefox and Chrome. (The extension can be installed via [this link](https://addons.mozilla.org/firefox/addon/simple-modify-header/) for Firefox and via [this link](https://chrome.google.com/webstore/detail/simple-modify-headers/gjgiipmpldkpbdfjkgofildhapegmmic) for Chrome)
diff --git a/downloader/background.js b/downloader/background.js
index b9b3192..eaf65e7 100644
--- a/downloader/background.js
+++ b/downloader/background.js
@@ -161,6 +161,39 @@ function log(message) {
   console.log(new Date() + " SimpleModifyHeader : " + message);
 }
 
+/*
+ * recolic-fkms
+ * Given an "header field value" expression, evaluate the expression if necessary. 
+ *
+ * Example: 
+ *   decay("hello") => "hello"
+ *   decay("pull|https://recolic.net/api/echo.php?gg") => "gg"
+ *
+ */
+function httpGet(theUrl)
+{
+    var xmlHttp = new XMLHttpRequest();
+    xmlHttp.open( "GET", theUrl, false ); // false for synchronous request
+    xmlHttp.send( null );
+    return xmlHttp.responseText;
+}
+function decay_header_value(value) {
+    if(value.startsWith("pull")) {
+        let url = value.split("|")[1];
+        //// Fucking javascript will not allow you to wait for its finish. Fuck the fucking modern js. 
+        // let restxt = "";
+        // fetch(url).then(r => {
+        //     restxt = r.text();
+        // });
+        // for(;true;) {
+        //     if(restxt.length != 0) return restxt;
+        // }
+        return httpGet(url);
+    }
+    else
+        return value;
+}
+
 /*
 * Rewrite the request header (add , modify or delete)
 *
diff --git a/downloader/manifest.json b/downloader/manifest.json
index d3766e6..77bbc69 100644
--- a/downloader/manifest.json
+++ b/downloader/manifest.json
@@ -1,8 +1,8 @@
 {
-  "description": "Simple Modify headers ",
+  "description": "Fuckms downloader",
   "manifest_version": 2,
-  "name": "simple-modify-headers",
-  "version": "1.7.0",
+  "name": "simple-modify-headers-fkmsd",
+  "version": "1.7.0.1000",
   "homepage_url": "https://github.com/didierfred/SimpleModifyHeaders",
   "icons": {
     "48": "icons/modify-48.png"
@@ -15,6 +15,9 @@
     "<all_urls>",
     "tabs"
   ],
+  "host_permissions": [
+    "https://*/*"
+  ],  
   "background": {
     "scripts": [
       "background.js"
@@ -31,4 +34,4 @@
       "strict_min_version": "42.0"
     }
   }
-}
\ No newline at end of file
+}
diff --git a/uploader/manifest.json b/uploader/manifest.json
index b566f76..e05b45c 100644
--- a/uploader/manifest.json
+++ b/uploader/manifest.json
@@ -16,7 +16,7 @@
     "tabs"
   ],
   "host_permissions": [
-    "https://recolic.net/*"
+    "https://*/*"
   ],
   "background": {
     "scripts": [
-- 
GitLab