Created
August 27, 2017 13:57
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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