feat: Add new calculator batches (6-10) and associated deployment/verification scripts, and update the calculator list.
This commit is contained in:
58
patch_b6.py
Normal file
58
patch_b6.py
Normal file
@@ -0,0 +1,58 @@
|
||||
import urllib.request
|
||||
import json
|
||||
import base64
|
||||
import time
|
||||
|
||||
creds = base64.b64encode(b"ben:6YGf wVxu gBpz pkqx BGZO lfVP").decode("utf-8")
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Basic " + creds,
|
||||
"User-Agent": "Mozilla/5.0"
|
||||
}
|
||||
|
||||
def get_js(f):
|
||||
return f"""<script>
|
||||
(function() {{
|
||||
function init() {{
|
||||
var i1 = document.getElementById("input-1");
|
||||
var i2 = document.getElementById("input-2");
|
||||
if (!i1 || !i2) {{
|
||||
if (window.r < 50) {{
|
||||
window.r++;
|
||||
setTimeout(init, 100);
|
||||
}}
|
||||
return;
|
||||
}}
|
||||
i1.oninput = function() {{
|
||||
var v = parseFloat(i1.value);
|
||||
if (isNaN(v)) {{ i2.value = ""; return; }}
|
||||
i2.value = parseFloat((v * {f}).toFixed(8));
|
||||
}};
|
||||
i2.oninput = function() {{
|
||||
var v = parseFloat(i2.value);
|
||||
if (isNaN(v)) {{ i1.value = ""; return; }}
|
||||
i1.value = parseFloat((v / {f}).toFixed(8));
|
||||
}};
|
||||
}}
|
||||
window.r = 0;
|
||||
init();
|
||||
}})();
|
||||
</script>"""
|
||||
|
||||
units = [
|
||||
(235, 0.0321507466), # Grams to Apothecary Ounces
|
||||
(237, 5.0), # Grams to Carats
|
||||
(239, 15.4323584), # Grams to Grains
|
||||
(241, 0.745699872) # Horsepower to Kilowatts
|
||||
]
|
||||
|
||||
for eid, f in units:
|
||||
data = json.dumps({'content': get_js(f)}).encode('utf-8')
|
||||
url = f'https://howdoyouconvert.com/wp-json/wp/v2/kadence_element/{eid}'
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method='PUT')
|
||||
try:
|
||||
urllib.request.urlopen(req)
|
||||
print(f"Patched {eid}")
|
||||
except Exception as e:
|
||||
print(f"Error {eid}: {e}")
|
||||
time.sleep(1)
|
||||
Reference in New Issue
Block a user