xcv58 / Custom-JavaScript-for-Websites-2

Run custom JavaScript on any website
https://xcv58.xyz/inject-js
MIT License
180 stars 46 forks source link

Regex not working correctly #933

Open howdyAnkit opened 6 months ago

howdyAnkit commented 6 months ago

Regex entered webste Link not functioning properly I created a new script and entered the website name in the mentioned area. After entering it I noticed even though the entered website is proper and regex tested against it was correct aswell. the plugin was not able to execute the script mentioned it is only working for a normal url and hence my script is impacting the other part of website which I wont like it to be working.

Url : https://xxx.websitename.com Now the above url works fine but it's getting applied to each and every page instead based on the route

For Eg : I'd Like to execute a diff script for https://xxx.websitename.com/abc and similarly diff script for https://xxx.websitename.com/def

my only requirement was to execute the script for a specific page abc and diff scripts for other parts of route. i did tested my regex on the mentioned link it seems to be correct. i also tried a workaround by using the window.location.href to find the correct route and execute the script but onchange of routes it still dosent function properly the same script gets applied here aswell for def instead the script was for the abc.

Please let me know if theres any work around to fix this. id like to contribute if maybe someone can point out what part of code is causing this

xcv58 commented 6 months ago

i also tried a workaround by using the window.location.href to find the correct route and execute the script but onchange of routes it still dosent function properly the same script gets applied here aswell for def instead the script was for the ABC.

I just tested this .*github.com/xcv58 regex and it works as expected (has the xcv58 log on https://github.com/xcv58/Custom-JavaScript-for-Websites-2/blob/master/src/js/libs/index.tsx page but not https://github.com/).

image

Could you please double check your regex?

Please let me know if theres any work around to fix this. id like to contribute if maybe someone can point out what part of code is causing this

Here is the matching logic https://github.com/xcv58/Custom-JavaScript-for-Websites-2/blob/be606622cddda00ccac1d196161e71e2679acdb7/src/js/libs/index.tsx#L97

You can see it's implement here and you can reproduce this locally by passing the regex and your href.