lundi 2 mars 2020

How could you generate a random string of letters/numbers and append them to an HTML link by clicking a button with JS?

I want to be able to have a link like www.example.com/ab1234 where the first "ab" are randomly generated letters between a-z and "1234" are randomly generated numbers 0-9 so whenever I run it a new www.example.com/ex1234 is generated.

I'm currently trying to make a Tampermonkey script to do this and found the following code for button generation

  $('body').append('<input type="button" value="Open Links" id="CP">')
  $("#CP").css("position", "fixed").css("top", 0).css("left", 0);
  $('#CP').click(function(){
    $.each(hrefs, function(index, value) {
      setTimeout(function(){
       window.open(value, '_blank');
      },1000);
    });
  });
});



Aucun commentaire:

Enregistrer un commentaire