JSFiddle - React, Tailwind, and code Playground
HTML
<body>
<input type="button" id="open" value="Open Compose" />
<input type="button" id="init" value="Init Streak" />
</body>
JavaScript
var Gmail = {
openCompose: function() {
alert('opening a compose window');
}
}
var Streak = {
addButtons: function() {
alert('adding Streaks buttons');
},
init: function() {
Gmail.originalOpenCompose = Gmail.openCompose;
Gmail.openCompose = function() {
Gmail.originalOpenCompose();
Streak.addButtons();
}
//I just don't want you clicking this twice.
$("#init").hide();
}
}
$("#open").click(function() {
Gmail.openCompose();
});
$("#init").click(function() {
Streak.init();
});