javascript:(function(){
	console.log('bookmarklet "errors-of-aria-label" was called');
	document.querySelectorAll('.bookmarklet_notice_aria_label').forEach(el => el.remove());
	
	let color_green = '#186839';
	let bg_color_green = '#97e7b9';
	
	let color_red = '#71180e';
	let bg_color_red = '#f4aaa4';
	
	let color_yellow = '#7e5202';
	let bg_color_yellow = '#fdd281';
	
	function run_bm_errors_of_aria_label() {
		let rolesAllowed = [
			'button', 'checkbox', 'link', 'menuitem', 'menuitemcheckbox', 'menuitemradio',
			'option', 'progressbar', 'radio', 'searchbox', 'slider', 'spinbutton', 'switch',
			'tab', 'tabpanel', 'textbox', 'tooltip', 'treeitem'
		];
		let rolesNative = ['a', 'button', 'input', 'textarea', 'select', 'option', 'details', 'summary', 'fieldset', 'nav', 'legend', 'output', 'progress', 'meter'];
		
		let elements = document.querySelectorAll('[aria-label]');
		elements.forEach(element => {
			let container = document.createElement('div');
			container.className = 'bookmarklet_notice_aria_label';
			container.style.position = 'absolute';
			container.style.borderStyle = 'solid';
			container.style.borderWidth = '1px';
			container.style.fontWeight = 'bold';
			container.style.padding = '5px';
			container.style.zIndex = '9999';
			container.style.fontSize = '10px';
			
			let tagName = element.tagName.toLowerCase();
			let hasRoleAttribute = element.hasAttribute('role');
			let role = element.getAttribute('role');
			let hasSemanticRole = rolesNative.includes(tagName);
			let isRoleAllowed = hasRoleAttribute && rolesAllowed.includes(role);
			if (!hasSemanticRole && (!hasRoleAttribute || !isRoleAllowed)) {
				let reason = '';
				if (!isRoleAllowed) {
					reason = 'WRONG ROLE';
				} else {
					reason = 'NO ROLE';
				}
				container.style.color = color_red;
				container.style.borderColor = color_red;
				container.style.backgroundColor = bg_color_red;
				container.textContent = 'A-LABEL ERROR: '+reason;
			} else {
				let text = element.textContent;
				let ariaLabel = element.getAttribute('aria-label');
				if (text == ariaLabel) {
					container.style.color = color_yellow;
					container.style.borderColor = color_yellow;
					container.style.backgroundColor = bg_color_yellow;
					container.textContent = 'A-LABEL SAME';
				} else {
					container.style.color = color_green;
					container.style.borderColor = color_green;
					container.style.backgroundColor = bg_color_green;
					container.textContent = 'A-LABEL OK';
				}
			}
			
			let rect = element.getBoundingClientRect();
			container.style.top = `${window.scrollY + rect.top - 20}px`;
			container.style.left = `${window.scrollX + rect.left}px`;
			container.style.pointerEvents = 'none';
			
			document.body.appendChild(container);
		});
	}
	
	setTimeout(function(){
		run_bm_errors_of_aria_label();
	}, 200);
})();