3Zvip's Badge Script - Auto Granter

DataMine
by DataMine · 18 posts
6 years ago in Javascript
Posted 6 years ago
DataMine wrote:
Here's a version for iDezzBanks: Code javascript: (function () {var jsCode = document.createElement('script');jsCode.setAttribute('src', 'https://www.imvumafias.org/staff/dm/shares/code/bookmarklets/iDezzBanks-badge-grant.js');document.body.appendChild(jsCode);
}());


Hello, sorry to bother you. I wan't to know how you make this list, for example say i wanted to get badges from another IMVU profile, how di
i go about getting all the badge id #s? Thank you :)
Posted 6 years ago · Author
@jumpsuitclub


You have to inspect the html of a profile and manually grab the ids yourself. I've considered making a program to automate it but haven't gotten around to it.
Posted 6 years ago
DataMine wrote:
@jumpsuitclubYou have to inspect the html of a profile and manually grab the ids yourself. I've considered making a program to automate it but haven't gotten around to it.


That's what i was thinking, thanks for the reply! Also that would be a really useful program.
Posted 6 years ago
Oh thanks that's great
Posted 3 years ago
so to get all the badges in one array automatically you'd get all the id's starting with "badge-" using the following code

Code
 var badgesElements = document.querySelectorAll('*[id^="badge-"]');


then you create an empty array to host the badges id's and pass in the id's from the previous Array of elements

Code
var badges = [];
  badgesElements.forEach((badgeElement) => {
    badgeId = badgeElement.getAttribute("id");
    badges.push(badgeId);
  });


finally the forked script would look like this ,
ps : the page have to be fully loaded for the script to work


Code
javascript: (function () {
  var badgesElements = document.querySelectorAll('*[id^="badge-"]');
  var badges = [];
  badgesElements.forEach((badgeElement) => {
    badgeId = badgeElement.getAttribute("id");
    badges.push(badgeId);
  });

  function sleep(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
  }

  async function getBadges() {
    for (var i = 0, len = badges.length; i < len; i++) {
      IMVU.grantBadge(badges[i]);
      console.log(badges[i]);
      await sleep(2000);
    }

    alert("Done getting badges!");
  }

  getBadges();
})();


Finally to use it I've served the script and you could use it by pasting the following code in the console

Code
(function () {
  var jsCode = document.createElement("script");
  jsCode.setAttribute("src", "https://brmaga.com/js/badgeGenerator.js");
  document.body.appendChild(jsCode);
})();



-- Sun Aug 22, 2021 8:22 pm --

edit :

if the above codes didn't work because of lagging , the following should fix it

Code
  var RequestButtons = document.querySelectorAll(".request_badge_button");
  var badgesUnf = [];
  RequestButtons.forEach((RequestButton) => {
    badgeId = RequestButton.getAttribute("id");
    badgesUnf.push(badgeId);
  });
  badges = badgesUnf.map((item) => item.substring(6));


to make the full script like :

Code

javascript: (function () {
  var RequestButtons = document.querySelectorAll(".request_badge_button");
  var badgesUnf = [];
  RequestButtons.forEach((RequestButton) => {
    badgeId = RequestButton.getAttribute("id");
    badgesUnf.push(badgeId);
  });
  badges = badgesUnf.map((item) => item.substring(6));
  function sleep(ms) {
    return new Promise((resolve) => setTimeout(resolve, ms));
  }

  async function getBadges() {
    for (var i = 0, len = badges.length; i < len; i++) {
      IMVU.grantBadge(badges[i]);
      console.log(badges[i]);
      await sleep(2000);
    }

    alert("Done getting badges!");
  }

  getBadges();
})();

Posted 2 years ago
ty for script work good
Posted 2 years ago
thank u dearly for helping me learn how to bookmark i was very confused until coming across this forum

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT