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

229
Visualizações
tampermonkey script to open website doesnt work

I use this script to open a specific link in a div of a webpage:

     // ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://www.tampermonkey.net/index.php?version=4.13&ext=dhdg&updated=true
// @icon         https://www.google.com/s2/favicons?domain=tampermonkey.net
// @grant        none
 // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// ==/UserScript==

 $(document).ready(function()
                   {
let url = $(".cta-button-container__item").attr('href');
    window.location.href = url;
});

the inspect elements for the link in the page is:

<div class="cta-button-container__item">
                    <a href="/content/pdf/xxxx.pdf" title="Download this book in PDF format" target="_blank" rel="noopener" class="c-button c-button--blue c-button__icon-right test-bookpdf-link" data-track="click" data-track-action="Book download - pdf" data-track-label="">
                        <svg width="12" height="14" viewBox="0 0 12 14" xmlns="http://www.w3.org/2000/svg"><path d="M7 7.269v-6.271c0-.551-.448-.998-1-.998-.556 0-1 .447-1 .998v6.271l-1.5-1.547c-.375-.387-1.01-.397-1.401-.006l.016-.016c-.397.397-.391 1.025-.001 1.416l3.178 3.178c.392.392 1.024.391 1.415 0l3.178-3.178c.392-.392.391-1.025-.001-1.416l.016.016c-.397-.397-1.018-.388-1.401.006l-1.5 1.547zm-7 5.731c0-.552.456-1 1.002-1h9.995c.554 0 1.002.444 1.002 1 0 .552-.456 1-1.002 1h-9.995c-.554 0-1.002-.444-1.002-1z" fill="#fff"></path></svg>
                        <span>Download book PDF</span>
                    </a>
                </div>

Unfortunately tampermonkey says no script is running.

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

0

after more search and i edited the script and it works perfectly:

    // ==UserScript==
// @name         New Userscript
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://link.springer.com/book/*/*
// @icon         https://www.google.com/s2/favicons?domain=tampermonkey.net
// @grant        none
 // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
// ==/UserScript==

 $(document).ready(function()
                   {
    let url = $(".cta-button-container__item a").attr('href');
    window.location.href = url;
});

I forgot to add the a which is equivalent to .find("a") . I changed the url of the filter to https://link.springer.com/book/*/*. the (/) just means any address beginning with the previous link.

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