Compare commits

..

2 Commits

2 changed files with 125 additions and 0 deletions

View File

@ -0,0 +1,71 @@
<#
use this order to reformat json objects:
version
description
homepage
license
notes
depends
suggest
architecture
url
hash
extract_dir
extract_to
pre_install
installer
post_install
env_add_path
env_set
bin
shortcuts
persist
pre_uninstall
uninstaller
post_uninstall
checkver
autoupdate
#>
# Read all json files in the current directory
Get-ChildItem -Filter *.json | ForEach-Object {
# Read the file
$json = Get-Content $_.FullName | ConvertFrom-Json -Depth 9
# Create a new object with the properties in the desired order
$newJson = [ordered]@{
version = $json.version
description = $json.description
homepage = $json.homepage
license = $json.license
notes = $json.notes
depends = $json.depends
suggest = $json.suggest
architecture = $json.architecture
url = $json.url
hash = $json.hash
extract_dir = $json.extract_dir
extract_to = $json.extract_to
pre_install = $json.pre_install
installer = $json.installer
post_install = $json.post_install
env_add_path = $json.env_add_path
env_set = $json.env_set
bin = $json.bin
shortcuts = $json.shortcuts
persist = $json.persist
pre_uninstall = $json.pre_uninstall
uninstaller = $json.uninstaller
post_uninstall = $json.post_uninstall
checkver = $json.checkver
autoupdate = $json.autoupdate
}
# Remove any null properties
$newJson = $newJson | Where-Object { $_.Value -ne $null }
# Convert the new object back to json and write it back to the file
$newJson | ConvertTo-Json -Depth 9 | Set-Content $_.FullName
}
# Run scoop json prettier on all json files in the current directory
~/scoop/apps/scoop/current/bin/formatjson.ps1 -Dir .

54
ShowTax/showtax.js Normal file
View File

@ -0,0 +1,54 @@
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 2024-04-12
// @description try to take over the world!
// @author You
// @match https://www.amazon.ca/*
// @grant none
// @run-at document-idle
// ==/UserScript==
(function() {
const TAX = 0.15;
// Todo: decide if it should just round up to the nearest dollar
// Todo: fix queryselectorall only finding one element at a time
const changeNode = function(node) {
var wholeNode = node.querySelector('.a-price-whole');
var fractionNode = node.querySelector('.a-price-fraction');
var whole = wholeNode ? wholeNode.textContent : '0';
var fraction = fractionNode ? fractionNode.textContent : '0';
whole = parseInt(whole);
fraction = parseInt(fraction);
whole += whole * TAX;
fraction += fraction * TAX;
whole = Math.floor(whole);
fraction = Math.floor(fraction);
if (fraction >= 100) {
whole += 1;
fraction -= 100;
}
if (fraction < 10) {
fraction = '0' + fraction;
}
wholeNode.textContent = whole;
fractionNode.textContent = fraction;
}
const find = function() {
console.log("Finding price nodes");
document.querySelectorAll('.a-price').forEach((node) => {
if (node.attributes['found']) {
return;
}
node.attributes['found'] = true;
console.log(node);
console.log("Price node found")
changeNode(node);
});
}
//find();
setInterval(find, 1000);
})();