Discussions » Development

Error in code. "contains"

§
Posted: 2018-03-08
Edited: 2018-03-08

Error in code. "contains"

document.location = document.querySelector("A.zmW.tdNone[href*='battle']:contains('LinkName')").href;
This code isnt work, but this work
document.location = document.querySelector("A.zmW.tdNone[href*='battle']").href;
how to use to work together with
:contains('LinkName')
where is the mistake? Tell me please. If that I'm a novice and do not understand much. Thank you in advance for your help!

wOxxOmMod
§
Posted: 2018-03-08
Edited: 2018-03-08

contains() is a jQuery selector so it doesn't work in standard DOM method like querySelector. You need to include jquery.js in your usercsript metablock (example) and switch to $ function:

location = $("A.zmW.tdNone[href*='battle']:contains('LinkName')").attr("href")
§
Posted: 2018-03-08

Tell me, please, how to include jquery.js

wOxxOmMod
§
Posted: 2018-03-08

See the linked example in my post above.

Post reply

Sign in to post a reply.