@@ -649,9 +649,9 @@ let waitForElementsAndRun = setInterval(() => {
649
649
const source = r"""
650
650
// ==UserScript==
651
651
// @name auto-stock-fill
652
- // @namespace dev.kwack.torn.scripts
653
- // @version 1.0.0
654
- // @description Automatically fill your company's stock order
652
+ // @namespace https://github.com/Kwack-Kwack/pda-userscripts
653
+ // @version 1.0.2
654
+ // @description Automatically fill your company's stock
655
655
// @author Kwack [2190604]
656
656
// @match https://www.torn.com/*
657
657
// @grant none
@@ -670,12 +670,12 @@ let waitForElementsAndRun = setInterval(() => {
670
670
}
671
671
function callback(form) {
672
672
const storageCap = Array.from(form.querySelectorAll(".storage-capacity > *")).map((el) =>
673
- parseInt (el.innerText),
673
+ getNumber (el.innerText),
674
674
);
675
675
const usableCap = storageCap[1] - storageCap[0];
676
- const totalSoldDaily = parseInt (form.querySelector(".stock-list > li.total .sold-daily").textContent);
676
+ const totalSoldDaily = getNumber (form.querySelector(".stock-list > li.total .sold-daily").textContent);
677
677
Array.from(form.querySelectorAll(".stock-list > li:not(.total):not(.quantity)")).forEach((el) => {
678
- const soldDaily = parseInt (el.querySelector(".sold-daily").lastChild.textContent);
678
+ const soldDaily = getNumber (el.querySelector(".sold-daily").lastChild.textContent);
679
679
const neededStock = Math.max((soldDaily / totalSoldDaily) * usableCap, 0);
680
680
updateInput(el.querySelector("input"), Math.floor(neededStock).toString());
681
681
});
@@ -715,6 +715,9 @@ let waitForElementsAndRun = setInterval(() => {
715
715
input.dispatchEvent(new Event("change", { bubbles: true }));
716
716
input.dispatchEvent(new Event("input", { bubbles: true }));
717
717
}
718
+ function getNumber(str) {
719
+ return parseInt(str.replace(/,/g, ""));
720
+ }
718
721
})();
719
722
""" ;
720
723
0 commit comments