23 lines
786 B
Diff
23 lines
786 B
Diff
diff --git a/owug.py b/owug.py
|
|
index b29f62f..6800440 100644
|
|
--- a/owug.py
|
|
+++ b/owug.py
|
|
@@ -75,6 +75,18 @@ for item in head:
|
|
|
|
item.attrs['href'] = f'data:{css_mime_type};base64,{b64encode_as_string(bytes(style_data, 'utf-8'))}'
|
|
|
|
+# hardcode javascript
|
|
+# doing it this way rather than like the css because where in the page it is matters
|
|
+js = soup.find_all('script')
|
|
+for item in js:
|
|
+ if 'src' in item.attrs:
|
|
+ url = absolute_url(item.attrs['src'], domain_thing)
|
|
+ mime_type = requests.head(url).headers['Content-Type']
|
|
+ as_base64 = b64encode_as_string(requests.get(url).content)
|
|
+ new_url = f'data:{mime_type};base64,{as_base64}'
|
|
+
|
|
+ item.attrs['src'] = new_url
|
|
+
|
|
# change relative links to absolute
|
|
links = soup.find_all('link')
|
|
for item in links:
|