Compare commits
3 Commits
2987221c93
...
b5e30e467b
Author | SHA1 | Date | |
---|---|---|---|
|
b5e30e467b | ||
|
55ef1a788f | ||
|
f60f5350ef |
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -1187,7 +1187,6 @@ dependencies = [
|
|||||||
"tokio",
|
"tokio",
|
||||||
"tracing",
|
"tracing",
|
||||||
"tracing-subscriber",
|
"tracing-subscriber",
|
||||||
"url",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
@ -8,5 +8,4 @@ rocket = {path = "../Rocket/core/lib"}
|
|||||||
tokio = { version = "1.40.0", features = ["full"] }
|
tokio = { version = "1.40.0", features = ["full"] }
|
||||||
tracing = "0.1.40"
|
tracing = "0.1.40"
|
||||||
tracing-subscriber = "0.3.18"
|
tracing-subscriber = "0.3.18"
|
||||||
url = "2.5.2"
|
|
||||||
minio = {git="https://github.com/minio/minio-rs.git", rev = "c28f576"}
|
minio = {git="https://github.com/minio/minio-rs.git", rev = "c28f576"}
|
||||||
|
13
browser/background.js
Normal file
13
browser/background.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
function handle(requestDetails) {
|
||||||
|
let b64 = btoa(requestDetails.url)
|
||||||
|
// let original = atob(b64);
|
||||||
|
// console.log(`Loading: ${requestDetails.url} || ${b64}`);
|
||||||
|
|
||||||
|
return {
|
||||||
|
redirectUrl: `http://localhost:4433/s3/${b64}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
browser.webRequest.onBeforeRequest.addListener(
|
||||||
|
handle, { urls: ["<all_urls>"] }, ["blocking"]
|
||||||
|
);
|
@ -1,14 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta charset="utf-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<title></title>
|
|
||||||
<meta name="description" content="">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1>Now click "load" in the extension window</h1>
|
|
||||||
<div id="anchor" hidden></div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -4,8 +4,14 @@
|
|||||||
"version": "0.1",
|
"version": "0.1",
|
||||||
"description": "Adds a red border to all webpages matching mozilla.org.",
|
"description": "Adds a red border to all webpages matching mozilla.org.",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"activeTab"
|
"activeTab",
|
||||||
|
"webRequest",
|
||||||
|
"webRequestBlocking",
|
||||||
|
"<all_urls>"
|
||||||
],
|
],
|
||||||
|
"background": {
|
||||||
|
"scripts": ["background.js"]
|
||||||
|
},
|
||||||
"browser_action": {
|
"browser_action": {
|
||||||
"default_icon": "icon.png",
|
"default_icon": "icon.png",
|
||||||
"default_title": "Click me!",
|
"default_title": "Click me!",
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
|
|
||||||
let anchor = document.getElementById('anchor');
|
|
||||||
if (anchor) {
|
|
||||||
window.fetch(anchor.innerText)
|
|
||||||
.then(res => res.text())
|
|
||||||
.then((body) => {
|
|
||||||
document.body.textContent = "";
|
|
||||||
document.body.innerHTML = body;
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -5,10 +5,9 @@
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<button id="newtab">Open canvas</button>
|
<button id="">On</button>
|
||||||
<button id="replacer">Load page</button>
|
<button id="">Off</button>
|
||||||
<p id="output"></p>
|
<p id="output"></p>
|
||||||
<script src="popup.js"></script>
|
|
||||||
</body>
|
</body>
|
||||||
<style>
|
<style>
|
||||||
html {
|
html {
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
const output = document.getElementById('output');
|
|
||||||
let page_url = "http://127.0.0.1:4433/s3/style.css";
|
|
||||||
|
|
||||||
document.getElementById("newtab").addEventListener('click', async function(e) {
|
|
||||||
browser.tabs.create({ url: "/main/main.html" }).then((t) => {
|
|
||||||
if (t.id) {
|
|
||||||
output.innerText += t.id
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
document.getElementById("replacer").addEventListener('click', async function(e) {
|
|
||||||
browser.tabs.executeScript({ code: injection })
|
|
||||||
browser.tabs.executeScript({ file: "inject.js" });
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
const injection = `
|
|
||||||
let head = document.getElementById('anchor');
|
|
||||||
head.innerText = "${page_url}";
|
|
||||||
`
|
|
17
src/main.rs
17
src/main.rs
@ -1,7 +1,6 @@
|
|||||||
use rocket::{fairing::{Fairing, Info, Kind}, fs::FileServer, get, http::Header, routes, Request, Response, State};
|
use rocket::{fairing::{Fairing, Info, Kind}, fs::FileServer, get, http::Header, routes, Request, Response, State};
|
||||||
use s3::S3;
|
use s3::S3;
|
||||||
use tracing::{info, Level};
|
use tracing::{info, Level};
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
mod s3;
|
mod s3;
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ async fn main() {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
let config = Config {
|
let config = Config {
|
||||||
s3_bucket: "v1.10",
|
s3_bucket: "b64v1",
|
||||||
s3_url: "http://localhost:9000",
|
s3_url: "http://localhost:9000",
|
||||||
s3_access_key: "8UO76z8wCs9DnpxSbQUY",
|
s3_access_key: "8UO76z8wCs9DnpxSbQUY",
|
||||||
s3_secret_key: "xwKVMpf2jzgprsdo85Dvo74UmO84y0aRrAUorYY5",
|
s3_secret_key: "xwKVMpf2jzgprsdo85Dvo74UmO84y0aRrAUorYY5",
|
||||||
@ -42,14 +41,12 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/s3/<path>")]
|
#[get("/s3/<path>")]
|
||||||
async fn get_s3_content(path: &str, db: &State<S3>) -> String {
|
async fn get_s3_content(path: &str, db: &State<S3>) -> Option<String> {
|
||||||
info!(path);
|
if let Some(resp) = db.get(&path).await {
|
||||||
// TODO this is just pseudo-code
|
return Some(resp)
|
||||||
let url = "en.wikipedia.org/wiki/CNBC";
|
|
||||||
if let Some(resp) = db.get(&url).await {
|
|
||||||
return resp
|
|
||||||
}
|
}
|
||||||
"Hello world.".to_owned()
|
// instead of some/none I would rather this be 200/404
|
||||||
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
// CORS, to allow other sites to request this from their front-end
|
// CORS, to allow other sites to request this from their front-end
|
||||||
@ -69,5 +66,7 @@ impl Fairing for CORS {
|
|||||||
response.set_header(Header::new("Access-Control-Allow-Methods", "POST, GET, PATCH, OPTIONS"));
|
response.set_header(Header::new("Access-Control-Allow-Methods", "POST, GET, PATCH, OPTIONS"));
|
||||||
response.set_header(Header::new("Access-Control-Allow-Headers", "*"));
|
response.set_header(Header::new("Access-Control-Allow-Headers", "*"));
|
||||||
response.set_header(Header::new("Access-Control-Allow-Credentials", "true"));
|
response.set_header(Header::new("Access-Control-Allow-Credentials", "true"));
|
||||||
|
// TODO set this automatically like how Rocket/core/lib/src/fs/server.rs does (bottom of file)
|
||||||
|
response.set_header(Header::new("Content-Type", "text/html"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ use minio::s3::{
|
|||||||
args::{BucketExistsArgs, MakeBucketArgs}, client::ClientBuilder, creds::StaticProvider, error::Error, http::BaseUrl, types::S3Api, Client
|
args::{BucketExistsArgs, MakeBucketArgs}, client::ClientBuilder, creds::StaticProvider, error::Error, http::BaseUrl, types::S3Api, Client
|
||||||
};
|
};
|
||||||
use tracing::{instrument, trace};
|
use tracing::{instrument, trace};
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
use crate::Config;
|
use crate::Config;
|
||||||
|
|
||||||
@ -35,7 +34,7 @@ impl S3 {
|
|||||||
.await?;
|
.await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
trace!("Connection successfull");
|
trace!("Connection successful");
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
bucket_name: config.s3_bucket.to_owned(),
|
bucket_name: config.s3_bucket.to_owned(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user