Last active
May 14, 2019 12:18
-
-
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.
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
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; | |
} | |
}); |
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
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