Skip to content

Instantly share code, notes, and snippets.

@MosheBerman
Created July 24, 2020 02:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MosheBerman/cd4a562fd4a12132f72a77981c7a790d to your computer and use it in GitHub Desktop.
Save MosheBerman/cd4a562fd4a12132f72a77981c7a790d to your computer and use it in GitHub Desktop.
/**
* 1. Filter matches to 6-8cM
* 2. Open the developer console in Chrome.
* 3. Paste this.
* 4. Scroll through matches. As you scroll they, will be automatically noted.
* Known bugs:
* - The first page of matches won't be automatic, but the rest will.
* - You may need to refresh the page to see notes.
*
* For educational purposes only.
*/
const pairOfIdsFromNode=e=>{if(!e)return void console.warn("No node.");const t=e.href;if(!e.href||0==e.href.length)return void console.warn("empty url.");if(!t.includes("/compare/"))return void console.warn("Not a compare URL.");const r=t.split("/").splice(-3),o=r[0],n=r[2];return o&&n?{myId:o,theirId:n}:void 0};let matchListBody=()=>document.querySelector(".match-list-body");const noteNodes=e=>{e.filter(e=>"A"===e.tagName).map(pairOfIdsFromNode).filter(e=>void 0!==e&&null!==e.myId&&null!==e.theirId).forEach(e=>requestForMatch(e))};let mutationHandler=(e,t)=>{[].concat(...e.map(e=>Array.from(e.addedNodes))).filter(e=>"A"===e.tagName).map(pairOfIdsFromNode).filter(e=>void 0!==e&&null!==e.myId&&null!==e.theirId).forEach(e=>requestForMatch(e))};const mutationObserver=new MutationObserver(mutationHandler),mutationObserverConfig={childList:!0,subtree:!0};mutationObserver.observe(matchListBody(),mutationObserverConfig);const note=()=>JSON.stringify({note:"under 8cM"}),requestURLFor=(e,t)=>`https://www.ancestry.com/discoveryui-matchesservice/api/samples/${e}/matches/${t}`,requestForMatch=({myId:e,theirId:t})=>{const r=requestURLFor(e,t),o=new XMLHttpRequest;o.addEventListener("readystatechange",e=>{console.log(`Req state change: ${e.target.status}`)}),o.open("PUT",r,!0),o.setRequestHeader("Content-Type","application/json"),o.send(note())};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment