How do you force a script to refire on every page load in Discourse?

Hi @lll, I am not sure about what’s exactly you are trying to achieve since I didn’t followed this topic fully. If you just want to modify all post contents as you described here then you can use below code

api.decorateCooked($elem => $elem.children('p').addClass('foo-class'));

https://github.com/discourse/discourse/blob/c5c1d8e1805f92743403e243644f1a8298f6877d/app/assets/javascripts/discourse/lib/plugin-api.js.es6#L116-L130

11 Likes