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.
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.