vendredi 1 mai 2020

Can't use if condition in JavaScripts (userscript)

I feel dumb for that question. I know how use if condition in bash and there are some differences that ruins my code. In bash you can write * character to show not care what there writen,^ for protocol and =~ for approximately equal. Example:

url = https://en.m.wikipedia.org/wiki/Solovetsky_Stone
if [[ $url =~ ^.*.wikipedia.org/wiki/* ]]

It find all wiki page in any language and in mobile mode or not. I don't know how do that in javascript. I can't use string1.localeCompare(string2) because it show only same (0) and aa (1,-1). I want run script in specific page via comparing url in userscript (javascript).

Sorry for my english.

Aucun commentaire:

Enregistrer un commentaire