Potherca
8/27/2017 - 1:57 PM

Changes the functionality of the "Enter password to allow" screen of the "BlockSite" Chrome extension to permanently allow a domain.

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*/