Home > database >  how to add new button via userscript at website
how to add new button via userscript at website

Time:01-22

i am very newbie, so much confused to ask you for help me to add a new button to a webpage via UserScript i tried several time but all my attempted failed, here is my button

<center> <button id="iabcc4f6ccb66734d26a4c190c889867d061" data-snip-rule="105" style="display: block;"> Continue </button></center>

would you mind to help me

i try to do it i just add this but can not handle the button

let btn = document.createElement("button"); btn.innerHTML = "Continue "; document.body.appendChild(btn);

CodePudding user response:

Unfortunately, this will not work as you need to specify an ID for the button and apply some styling.

To achieve what you are trying to do, you need to do the following:

  1. Create the button element using JavaScript and set the ID and style properties.
  2. Add the button to the page using JavaScript.
  3. Add an event listener to the button to handle any user interactions with the button.

For example:

let btn = document.createElement("button");
btn.id = "iabcc4f6ccb66734d26a4c190c889867d061";
btn.style.display = "block";
btn.innerHTML = "Continue";
document.body.appendChild(btn);

btn.addEventListener("click", function(){
    // do something here
});
  • Related