Skip to content

Instantly share code, notes, and snippets.

@Crecket
Last active May 14, 2019 12:18
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Crecket/073c6a5094d2eb01afb23c699a2d5da7 to your computer and use it in GitHub Desktop.
Save Crecket/073c6a5094d2eb01afb23c699a2d5da7 to your computer and use it in GitHub Desktop.
Adds a 'bunq' option to any select field which already contains an option containing ASN or ING.
const bunqOption = document.createElement("option");
bunqOption.appendChild(document.createTextNode("bunq"));
bunqOption.value = "BUNQNL2A";
document.querySelectorAll("select").forEach(select => {
const options = document.querySelectorAll(`#${select.id} option`);
let hasBankCode = false;
options.forEach(option => {
if (option.value && option.value.includes("ING")) hasBankCode = true;
if (option.innerHTML.includes("ING") || option.innerHTML.includes("ASN")) hasBankCode = true;
});
if (hasBankCode) {
select.prepend(bunqOption);
select.selectedIndex = 0;
}
});
javascript:var b=document.createElement("option");b.appendChild(document.createTextNode("bunq")),b.value="BUNQNL2A",document.querySelectorAll("select").forEach(function(e){var n=document.querySelectorAll("#"+e.id+" option"),c=!1;n.forEach(function(e){e.value&&e.value.includes("ING")&&(c=!0),(e.innerHTML.includes("ING")||e.innerHTML.includes("ASN"))&&(c=!0)}),c&&(e.prepend(b),e.selectedIndex=0)});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment