Last active
November 30, 2021 12:03
-
-
Save riccardomares/32717c67a4767851d57a77784f1a48ca 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
/* | |
This pack of functions consents to open/close the Google's "People also ask" questions. | |
Notes: | |
- aria-expanded = false (closed) | |
- aria-expanded = true (opened) | |
examples: | |
- <div jsname="bVEB4e" class="wWOJcd" aria-controls="exacc_BAumYejmNqiQ9u8PmYiV4Aw50" aria-expanded="false" aria-labelledby="exacc_BAumYejmNqiQ9u8PmYiV4Aw49" role="button" tabindex="0" jsaction="AWEk5c"> | |
- <div jsname="bVEB4e" class="wWOJcd" aria-controls="exacc_BAumYejmNqiQ9u8PmYiV4Aw50" aria-expanded="true" aria-labelledby="exacc_BAumYejmNqiQ9u8PmYiV4Aw49" role="button" tabindex="0" jsaction="AWEk5c"> | |
@author: Merlinox | |
Do you want to bookmarklet this? https://mrcoles.com/bookmarklet/ | |
*/ | |
//classname at 2021/11/30 | |
var gaaBaseClassName = "wWOJcd"; | |
//max questions | |
var maxQuestions = 200; | |
//export questions found | |
function escile(){ | |
qs = document.getElementsByClassName(gaaBaseClassName); | |
rs = ""; | |
for (i=0;i<qs.length;i++){ | |
if (rs!=""){ | |
rs += "\n"; | |
} | |
rs += qs[i].innerText; | |
} | |
alert("Le " + qs.length + " occorrenze sono in console!"); | |
console.log(rs.replaceAll(String.fromCharCode(63),"")); | |
} | |
//sleep for x ms | |
function sleep(miliseconds) { | |
var currentTime = new Date().getTime(); | |
while (currentTime + miliseconds >= new Date().getTime()) { | |
} | |
} | |
//open questions | |
function aprile(){ | |
var qs = document.getElementsByClassName(gaaBaseClassName); | |
var qsi = 0; | |
console.log("Aprile is working..."); | |
for (i=0;i<qs.length;i++){ | |
if (qs[i].getAttribute("aria-expanded") == "false"){ | |
qs[i].click(); | |
qsi++; | |
} | |
} | |
console.log("... I opened " + qsi + " questions"); | |
} | |
//close questions | |
function chiudile(){ | |
var qs = document.getElementsByClassName(gaaBaseClassName); | |
var qsi = 0; | |
for (i=0;i<qs.length;i++){ | |
if (qs[i].getAttribute("aria-expanded") == "true"){ | |
qs[i].click(); | |
qsi++; | |
} | |
} | |
console.log("... I closed " + qsi + " questions"); | |
} | |
//count questions | |
function contale(){ | |
qs = document.getElementsByClassName(gaaBaseClassName); | |
console.log("I found " + qs.length + " questions"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment