2014-03-01

Genderswap any webpage!

After trying to read the dismal The Claiming of Sleeping Beauty again, i thought it might be interesting to see whether it'd be more palatable with reversed genders. A difficult experience. Here's the code, which you can set as a bookmark location, then click the bookmark to transform the current page:

javascript:(function(){function swap(txt, a, b){return txt.split(a).join("SWPTMP").split(b).join(a).split("SWPTMP").join(b)};var subs=[[' he ',' she '],[' he\'',' she\''],['He ','She '],[' man ',' woman '],[' men',' women'],['boy','girl'],['King','Queen'],['Lord','Lady'],[' daughter',' son'],['father','mother'],['uncle','aunt'],['Prince','Princess'],[' herself',' himself'],[' her.',' him.'],[' her,',' him,'],[' her a ',' him a '],[' her an ',' him an '],[' her and ',' him and '],[' him to',' her to'],[' him up',' her up'],[' him down',' her down'],[' him again',' her again'],[' him until',' her until'],[' him w',' her w'],[' him by',' her by'],[' her ',' his '],['His ', 'Her ']];t=document.body.innerHTML;for(var i=0;i<subs.length;++i)t=swap(t, subs[i][0], subs[i][1]);document.body.innerHTML=t.replace('Princessss','Prince')})()

3 comments:

  1. Pairs don't conflict in the code i posted here: http://codegolf.stackexchange.com/questions/23476/swap-genders-on-this-page-code-golf/23485#23485

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. Ouch, what formatting. My icon's broken, too. I guess i should back up my Blogspot posts before Google kills them. Blogger is a frontend for Blogspot (or your domain): https://www.youtube.com/watch?v=85Jthf_hU5I

      Delete