This can be done with jquery as below:

$('div').on('click', 'a#CancelScripts', function() {
  console.log("Cancelling scripts..");
  localStorage.setItem('GotoBeginning', false);
  localStorage.setItem('GotoLast', false);
  return false;
});

Here, div is the parent element of tag that we wish to bind click to.