Skip to content

Instantly share code, notes, and snippets.

@minanagehsalalma
Created January 17, 2026 20:39
Show Gist options
  • Select an option

  • Save minanagehsalalma/22178e2b2dc914235b848b357f3b5b1e to your computer and use it in GitHub Desktop.

Select an option

Save minanagehsalalma/22178e2b2dc914235b848b357f3b5b1e to your computer and use it in GitHub Desktop.
a bookmarklet that will extract all values from dropdown menus on a page.
javascript:(function(){
const results = [];
// Find all dropdown menu containers
const dropdowns = document.querySelectorAll('.ddChild ul, .dropdown-menu, [class*="dropdown"] ul, [class*="menu"] ul');
dropdowns.forEach((dropdown, idx) => {
const items = dropdown.querySelectorAll('li');
if (items.length > 0) {
const menuItems = [];
items.forEach(item => {
const label = item.querySelector('.ddlabel, .label, span:first-child');
const description = item.querySelector('.description');
const text = {
label: label ? label.textContent.trim() : '',
description: description ? description.textContent.trim() : '',
fullText: item.textContent.trim().replace(/\s+/g, ' ')
};
if (text.label || text.fullText) {
menuItems.push(text);
}
});
if (menuItems.length > 0) {
results.push({
menu: idx + 1,
items: menuItems
});
}
}
});
// Format output
let output = '=== DROPDOWN MENU VALUES ===\n\n';
results.forEach(menu => {
output += `Menu ${menu.menu}:\n`;
menu.items.forEach((item, i) => {
output += ` ${i + 1}. ${item.label}`;
if (item.description) {
output += ` - ${item.description}`;
}
output += '\n';
});
output += '\n';
});
// Copy to clipboard
navigator.clipboard.writeText(output).then(() => {
alert(`✓ Copied ${results.reduce((sum, m) => sum + m.items.length, 0)} items from ${results.length} dropdown menu(s) to clipboard!`);
}).catch(err => {
// Fallback: show in a text area if clipboard fails
const textarea = document.createElement('textarea');
textarea.value = output;
textarea.style.cssText = 'position:fixed;top:10px;left:10px;width:80%;height:80%;z-index:999999;padding:10px;font-family:monospace;font-size:12px;';
document.body.appendChild(textarea);
textarea.select();
alert('Results displayed in text area. Press Ctrl+C to copy, then close this alert to remove the text area.');
setTimeout(() => textarea.remove(), 30000);
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment