Skip to content

Commit

Permalink
change build script
Browse files Browse the repository at this point in the history
  • Loading branch information
ading2210 committed Aug 5, 2023
1 parent 10f2761 commit 24cdf4e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
25 changes: 8 additions & 17 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@
import pathlib
import base64

extensions = {
"securly_new": "chrome-extension://joflmkccibkooplaeoinecjbmdebglab/fonts/Metropolis.css",
"securly_old": "chrome-extension://iheobagjkfklnlikgihanlhcddjoihkg/fonts/Metropolis.css",
"goguardian": "chrome-extension://haldlgldplgnggkjaafhelgiaglafanh/youtube-injection.js"
}

base_path = pathlib.Path(__file__).resolve().parent
template_path = base_path / "template.html"
out_path = base_path / "generated"
template_html = template_path.read_text()

for name, url in extensions.items():
html = template_html.replace("{{public_url}}", url)
html = html.replace("{{extension_name}}", name)
out_file = out_path / f"{name}.html"
out_file.write_text(html)
html = template_path.read_text()
out_file = out_path / f"main.html"
out_file.write_text(html)

minified = minify_html.minify(html, minify_js=True, do_not_minify_doctype=True)
html_encoded = base64.b64encode(minified.encode()).decode()
data_url = f"data:text/html;base64,{html_encoded}"
data_file = out_path / f"{name}_data_url.txt"
data_file.write_text(data_url)
minified = minify_html.minify(html, minify_js=True, do_not_minify_doctype=True, minify_css=True)
html_encoded = base64.b64encode(minified.encode()).decode()
data_url = f"data:text/html;base64,{html_encoded}"
data_file = out_path / "data_url.txt"
data_file.write_text(data_url)
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<title>LTMEAT on generic webpages</title>
</head>
<body>
<p>The webpages have to be extension-specific, so see the generated html files <a href="./generated">here</a>.</p>
<p>See the generated html files <a href="./generated">here</a>.</p>
</body>
</html>
2 changes: 0 additions & 2 deletions template.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@
catch (error) {
let error_msg = error+"";
return error_msg.includes("AbortError");
console.log(error);
}
}

Expand Down Expand Up @@ -132,7 +131,6 @@
create_iframes(extension.url);
}
buttons_container.append(button);
console.log(extension);
}
}

Expand Down

0 comments on commit 24cdf4e

Please sign in to comment.