<commit_before>// Declarations
var passwordMenuId, formId, passId;

function contextFunction(info, tab) {
	console.log(formId + " " + passId);
};

function handleMessages(msg) {
	if(msg.password == true) {
		passwordMenuId = chrome.contextMenus.create(
			{"title": "Setup a half-life password",
			 "contexts": ["all"],
			 "onclick": contextFunction});
		formId = msg.formId;
		passId = msg.passId;
		//console.log(msg.passId + " " + msg.formId);
	} else if(passwordMenuId) {
		chrome.contextMenus.remove(passwordMenuId);
		passwordMenuId = null;
	} 
}

// Scripting
chrome.extension.onConnect.addListener(function(port) {
	console.assert(port.name === "passhalf");
	port.onMessage.addListener(handleMessages);
});


<commit_msg>Added some more condition checking for add/remove menu entry<commit_after>// Declarations
var passwordMenuId, passId;

function contextFunction(info, tab) {
	console.log(passId);
};

function handleMessages(msg) {
	if((msg.password == true) && (!passwordMenuId)){
		passwordMenuId = chrome.contextMenus.create(
			{"title": "Setup a half-life password",
			 "contexts": ["all"],
			 "onclick": contextFunction});
		passId = msg.passId;
		//console.log(msg.passId + " " + msg.formId);
	} else if((msg.password == false ) && (passwordMenuId)) {
		chrome.contextMenus.remove(passwordMenuId);
		passwordMenuId = null;
	} 
}

// Scripting
chrome.extension.onConnect.addListener(function(port) {
	console.assert(port.name === "passhalf");
	port.onMessage.addListener(handleMessages);
});



{'fraction_non_alphanumeric': 0.15775577557755777, 'fraction_numerical': 0.0, 'mean_word_length': 4.853281853281853, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5055975', 'n_tokens_mistral': 528, 'n_tokens_neox': 495, 'n_words': 91}