问题
How do I tell firefox browser to do something with a link(etc string trim) that i have just clicked then go to the modified link?
Is is possible ? or is there an addon for this?
回答1:
You don't need to create a plugin for that. This can be done with a simple script and Greasemonkey.
It is also not necessary to add a click handler to every link. It is better to use event delegation:
document.addEventListener('click', function(event) {
if(event.target.nodeName === 'A') {
var href = event.target.href;
// change the URL
location.href = href;
event.preventDefault();
}
}, true);
来源:https://stackoverflow.com/questions/5368008/link-onclick-do-something-before-following-href