Skip to content

Instantly share code, notes, and snippets.

@RC0D3
Last active January 15, 2024 04:37
Show Gist options
  • Save RC0D3/1a8ca7bf24bea628030e2ed8b4b0e57d to your computer and use it in GitHub Desktop.
Save RC0D3/1a8ca7bf24bea628030e2ed8b4b0e57d to your computer and use it in GitHub Desktop.
POC - Proof of Concept G CSE
document.getElementsByClassName('area-basic')[0].style.display = 'none'; // G CSE
let inputSearch = document.getElementById('gsc-i-id1');
inputSearch.value = '';
inputSearch.value += 'e';
inputSearch.dispatchEvent(new KeyboardEvent('keydown', {'key': 'e'}));
inputSearch.value += 'l';
inputSearch.dispatchEvent(new KeyboardEvent('keydown', {'key': 'l'}));
inputSearch.value += 'e';
inputSearch.dispatchEvent(new KeyboardEvent('keydown', {'key': 'e'}));
inputSearch.value += 't';
inputSearch.dispatchEvent(new KeyboardEvent('keydown', {'key': 't'}));
function waitForElm(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}
const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
observer.disconnect();
resolve(document.querySelector(selector));
}
});
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
waitForElm('.gsc-completion-container').then((elm) => {
let results = elm.innerText;
elm.style.display = 'none'; //HIDE RESULTS (MAY BE REPLACE TR TO BR AND GET WITH textContent)
results = results.split('\n\n\n');
inputSearch.value = '';
inputSearch.dispatchEvent(new KeyboardEvent('keydown', {'key': ''}));
console.log(results);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment