js question? 

im trying to run a function every time the current url changes

like, not a page reload but just url change

but
window.addEventListener('locationchange', function);

is doing Nothing
i have no idea how to do this right tbh

js question? 

hashchange event works but that's for hashes after the url, not the whole thing itself

locationchange does Nothing
is there like a way to just,,, listen for all url bar change events

js question? 

@AgathaSorceress you have to use the history api, there must be a push and pop events and/or associated on functions

js question? 

@ashpie yeah but that only applies to history, it doesnt seem to trigger if i click on someone's profile for example

js question? 

@AgathaSorceress like on mastodon frontend?

js question? 

@ashpie yeah im injecting js with violentmonkey into web mastodon because i want to change a few things clientside but I'm not sure how to do this part

js question? 

@ashpie right now its just

window.addEventListener('locationchange', replaceIcons);

the rest works and is unrelated

js question? 

@AgathaSorceress oh right i just checked the mdn and i think i forgot how it worked sorry haha so i think you may need to catch link click events

js question? 

@AgathaSorceress i mean if you want to override default link navigation behaviour, you have to preventDefault()

js question? 

@AgathaSorceress this is kinda cursed and probably not a good idea but you can make a wrapper that overrides the builtin window.history.pushState() api, about like so

const realPushState = window.history.pushState.bind(window.history);
window.history.pushState = (state, title, url) => {
console.log("meow");
realPushState(state, title, url);
};

js question? 

@fef oof I'll try that

I'm currently trying to use a mutation observer Thing to check if the masto timeline title changes but right now its not working and aaa

js question? 

@AgathaSorceress @fef yeah hooking like this is going to be the way to go

Sign in to participate in the conversation
Eldritch Caf茅

Une instance se voulant accueillante pour les personnes queers, f茅ministes et anarchistes ainsi que pour leurs sympathisant路e路s. Nous sommes principalement francophones, mais vous 锚tes les bienvenu路e路s quelle que soit votre langue.

A welcoming instance for queer, feminist and anarchist people as well as their sympathizers. We are mainly French-speaking people, but you are welcome whatever your language might be.