I'm developing a Chrome Extension, which is to translate texts in web page such as YouTube. Things run well after content.js is injected.
However, when web navigation performs(triggered by click events), content.js never be injected again. Texts in the paged seems to be mixed up: Both the previous translated one with the New one.
It turns out that I have to clean the translated text before navigation . Is it possible for JavaScript to intercept the navigation process and inject a function like clean_up() before that?
pseudo code like this:
function clean_up(){
...do some thing...
}
function intercept_navigation(callback){
clean_up();
callback();
}
intercept_navigation();