Skip to content

Commit

Permalink
Fix importer not initializing properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Nov 28, 2024
1 parent da85c50 commit e6c1b0a
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions FreePackagesImporter/code.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// @namespace https://github.com/Citrinate
// @author Citrinate
// @description Transfer packages from SteamDB's free packages tool to the ASF Free Packages plugin
// @version 1.0.1
// @version 1.0.2
// @match *://steamdb.info/freepackages/*
// @connect localhost
// @connect 127.0.0.1
Expand Down Expand Up @@ -48,7 +48,8 @@
// Get displayed packages
var freePackages = null;
const packageRegex = new RegExp("Package ([0-9]+)");
var observer = new MutationObserver(() => {

function UpdatePackages() {
let newFreePackages = [];
let packages = document.querySelectorAll(".package");
for (let i = 0; i < packages.length; i++) {
Expand All @@ -60,8 +61,11 @@

freePackages = newFreePackages;
UpdateInterface();
});
}

var observer = new MutationObserver(() => UpdatePackages());
observer.observe(document.getElementById("freepackages"), { childList: true });
UpdatePackages();

// Get bot list
var bots = null;
Expand Down Expand Up @@ -245,7 +249,6 @@
}

if (freePackages.length == 0) {
Finish();
ShowMessage("There are no packages to add.");

return;
Expand Down

0 comments on commit e6c1b0a

Please sign in to comment.