Skip to content

Instantly share code, notes, and snippets.

@FrancescoSaverioZuppichini
Created March 23, 2021 18:51
Show Gist options
  • Save FrancescoSaverioZuppichini/e6e01186ec2f5aac4c40bf4f85f58a12 to your computer and use it in GitHub Desktop.
Save FrancescoSaverioZuppichini/e6e01186ec2f5aac4c40bf4f85f58a12 to your computer and use it in GitHub Desktop.
fix bias in google
function random_gender() {
let roll = Math.random()
let gender = roll > 0.5 ? 'He/She' : 'She/He'
return gender
}
function fix_bias() {
var biased_node = document.querySelectorAll("#tw-target > div > div > pre > span")[0]
var text = biased_node.innerText
var sentences = text.split('.')
var unbiased_text = ''
for (let sentece of sentences) {
text = sentece.replace(/(He|She)/g, random_gender())
unbiased_text += text
}
biased_node.innerText = unbiased_text
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment