Last active
May 13, 2020 02:52
-
-
Save andersonbosa/25a0b1c26132393c0bfb855b4ba80ea7 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Get task card from given search | |
* @param {String} searchString - string to find | |
* @param {String} [where] - selector context. | |
* default value is .task-title a | |
* @returns {Object[]} | |
*/ | |
function getCardId(searchString, where) { | |
if (!searchString) { | |
return | |
} | |
searchString = ('card_id/' + searchString) | |
if (!where) { | |
where = '.task-title a' | |
} | |
let elements = Array.from(document.querySelectorAll(where)); | |
if (elements.length) { | |
return elements.filter(element => element.href.replace(/http[?s]:\/\//gm, '') === searchString)[0] | |
} else { | |
return {} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment