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
| let highlight = (word) => { | |
| //get web page contents | |
| let str = document.body.innerHTML.toString(); | |
| //search and replace | |
| str = str.replaceAll( new RegExp(word, 'gi'), `<span style='background-color:red;color:#fff'>${word}</span>` ); | |
| //rebuild the webpage | |
| document.body.innerHTML = str; | |
| } | |
| //invoke function | |
| highlight("Simon"); |
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 search = (search, replace) => { | |
| //the string | |
| const str = "I love to eat banana and mango"; | |
| //replace all occurrences of the searched term | |
| return str.replaceAll( new RegExp(search, 'gi'), replace ); | |
| } | |
| //invoke the function | |
| console.log( search('BANANA', '🍌') ); | |
| console.log( search('MANGO', '🥭') ); |
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
| //the string | |
| const str = "My name is simon ugorji"; | |
| //using match method on it with the modifier | |
| console.log(str.match(new RegExp('Simon', 'i'))); |
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
| //the string | |
| const str = "My name is simon ugorji"; | |
| //using match method on it | |
| console.log(str.match(new RegExp('simon'))); |
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
| //the string | |
| const str = "My name is simon ugorji"; | |
| //using match method on it | |
| console.log(str.match(/simon/)); |
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
| //the string | |
| const str = "My name is simon ugorji"; | |
| //using match method on it | |
| console.log(str.match('simon')); |
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
| //attach event listener | |
| document.querySelector('#inp_search').addEventListener('input', function(){ | |
| //store the search query | |
| let value = this.value.trim(); | |
| //check if value is not empty | |
| if(value){ | |
| //store matching record IDs | |
| let matchingIDs = []; | |
| //loop index | |
| let ind = 1; |
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
| //get url | |
| const pageUrl = window.location.href; | |
| //get sitekey | |
| const siteKey = document.querySelector('[data-sitekey]').getAttribute('data-sitekey'); | |
| //invoke the solve captcha function | |
| solveCaptcha(siteKey, pageUrl); |
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
| function solveCaptcha(siteKey, pageUrl){ | |
| //make printing text easier | |
| let log = (text) => {console.log(text)}; | |
| let logErr = (text) => {console.error(text)}; | |
| //your api key | |
| const apiKey = "YOUR_API_KEY"; | |
| //make a GET request to 2captcha | |
| fetch(`https://2captcha.com/in.php?key=${apiKey}&method=userrecaptcha | |
| &googlekey=${siteKey}&pageurl=${pageUrl}&json=1`) |
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
| function solveCaptcha(siteKey, pageUrl){ | |
| const apiKey = "YOUR_API_KEY"; | |
| //make a GET request to 2captcha | |
| fetch(`https://2captcha.com/in.php?key=${apiKey} | |
| &method=userrecaptcha&googlekey=${siteKey}&pageurl=${pageUrl}&json=1`) | |
| .then(response => response.json()) | |
| .then(data => { | |
| //check if there's an error | |
| if(!data.status){ | |
| //print out error |