Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Potherca/c60cbbb64a0a37315c5fb6c2ef7f3769 to your computer and use it in GitHub Desktop.
Save Potherca/c60cbbb64a0a37315c5fb6c2ef7f3769 to your computer and use it in GitHub Desktop.
Changes the functionality of the "Enter password to allow" screen of the "BlockSite" Chrome extension to permanently allow a domain.
/* Add dependencies needed to call `addPageToStorage` */
$('head').append('<script src="chrome-extension://eiimnmioipafcokbfikbljfdeojpcgbh/options.js"></script>');
$('body').append('<span id="login_label" style="display:none;"></span>');
trackButton = function(){};
init = function(){};
/* Define our custom event handler */
function handleLoginEvent(event) {
if(event.keyCode === undefined || event.keyCode === 13){
if (passwordIsCorrect()) {
bgPage.actualBlockedActive = true;
addPageToStorage();
location.href = bgPage.actualBlockedFullUrl;
}else{
document.getElementById('login_error').innerHTML=translate('wrongpasswd');
}
}
};
/* Remove original event-handlers */
$('#login_password, #login_button').unbind();
/* Add form field used by `addPageToStorage` */
$('body').append('<input type="hidden" id="block_page" value="' + bgPage.cropUrl(bgPage.actualBlockedFullUrl).split('/')[0] + '"/>');
$('#main').append('<p><em>'+$('#block_page').val()+'</em></p>');
/* Add our custom event-handler */
$('#login_button').on('click', handleLoginEvent);
$('#login_password').on('keydown', handleLoginEvent);
/* Restore original event-handlers */
login();
/*DONE*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment