Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
saves a signal that you can then trigger whenever you want

tampermonkey uses JavaScript. if anyone here is a JavaScript wizard I'd be most thankful for even a direction towards that end. or to at least know if it's feasible or not. the idea is to click a button on a website (any). and then store whatever that button did. whereby we can then trigger it without it actually being there anymore (without it being present on the screen anymore). even if we change tabs or so.

so for example is we have a button that increases a number from 0 by an increment of 1 whenever it's clicked. then by storing what that button does with tampermonkey. we can simply initialize a keyboard value to equal that signal and click the key we want instead of having to bother with the button anymore

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If I understand your question then Yes, you can do that. With a bit more information perhaps I can provide a more detailed response.

First, how to add a button onto the page:

(function() {
    'use strict';

    //Look carefully - this is Not jQuery
    const $ = document.querySelector.bind(document);
    $('body').insertAdjacentHTML('beforeend', init_css() );

    //Get data saved last time, if available
    const rmbr = localStorage.getItem('myVarName');
    if (rmbr !== null){
        alert(rmbr);
    }
    
    setTimeout(() => {
        $('#mybutt').addEventListener('click', () => {
            alert('You clicked me');
            localStorage.setItem('myVarName','The data you want to save');
        });
    },300);
});

function init_css(){
    return `
    <button id="mybutt">Click My Buttn</button>
    <style id="jdInitCss">
        #mybutt{position:absolute;top:90px;left:45%;height:30px;width:120px;}
        #mybutt{background:#0073ea;color:white;padding-top:5px;text-align:center;}
        #mybutt{z-index:99999;}
    </style>
    `;
}

As for saving information, use LocalStorage. Super-easy. Here's a reference.

https://www.w3schools.com/jsref/met_storage_setitem.asp https://www.w3schools.com/jsref/met_storage_getitem.asp

Notes:

  1. The #mybutt event listener is created inside a setTimeout because you need a few nanoseconds for the button to be injected onto the page (via the init_css() function). Without the setTimeout, there's a good chance JavaScript will attempt to add an event listener onto a button that doesn't yet exist on the page (by just a handful of milliseconds... or, as Maxwell Smart used to say, "....missed it by THAT much...")

  2. Because of how TamperMonkey works, you may need a different (unique) script for each website you wish to use this on. Of course, you can create a script that adds a button onto every webpage you visit, but that is rarely what is desired. Also, you can add multiple //MATCH conditions so that one script will run on multiple websites, but then you have to be more advanced in how you save your localStorage data.

  3. With more information/feedback from you perhaps we can construct more helpful answers.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda