/    Sign up×
Community /Pin to ProfileBookmark

Autoselect item with TamperMonkey

Hi, I’m using [this website](https://www.bibliotechediroma.it/opac/.do) and trying to autoselect in “Digita o seleziona la biblioteca”:

_Municipio X > Biblioteca Elsa Morante_

I used this script in TamperMonkey, but the page doesn’t react, where am I wrong? Thank you!

“`
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.bibliotechediroma.it/opac/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=google.it
// @grant none
// ==/UserScript==

(function() {
‘use strict’;
document.querySelector(“button[class=’syw-comboselect-trigger’]”).click();document.querySelector(“li[data-group=’GR_10′] a[title]”).click();document.querySelector(“li[data-cd=’RMBO2′] a[class=’select’]”).click();
})();
“`

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumJan 02.2023 — I checked these instructions in the debugger and they worked fine.

Possible reasons why they don't work in Tampermonkey:

The loading procedure that initializes the selects is executed on document-ready, maybe your script is executed before this event fires.

Creating the selects is working asynchronously, thus your script is executed before they are ready. (Although this is implausible as the object the select is based on is visible in the source text statically).

Recommended measures:

Make sure that Tampermonkey executes your script after document-ready.

Try to delay execution by setTimeout.
Copy linkTweet thisAlerts:
@jjamesmorgan2Jan 02.2023 — I hope you will share such type of impressive contents again with us so that we can utilize it and get more advantage.

**Links removed by Site Staff so it doesn't look like you're spamming us. Please don't post them again.**
Copy linkTweet thisAlerts:
@parvaresauthorJan 02.2023 — Thanks very much, Sempervivum, seems working with a setTimeout delay!!

×

Success!

Help @parvares spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...