Geni Auto Expand Bio

Expand Bio sections automatically.

  1. // ==UserScript==
  2. // @name Geni Auto Expand Bio
  3. // @namespace 4525639+rautava@users.noreply.github.com
  4. // @version 1.5
  5. // @description Expand Bio sections automatically.
  6. // @author Tommi Rautava
  7. // @license CC0-1.0
  8. // @match https://www.geni.com/people/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=geni.com
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. let LOOP_INTERVAL = 300;
  14. let MAX_LOOP_COUNT = 20;
  15. let loopCount = 0;
  16.  
  17. function clickBioAnchor() {
  18. "use strict";
  19.  
  20. let readMoreElem = document.querySelector('a.toggle_link[id^="bio_"]');
  21.  
  22. if (readMoreElem) {
  23. readMoreElem.click();
  24. }
  25. }
  26.  
  27. function clickToShowMoreChildren() {
  28. let moreChildrenXpath = '//tr[@id="family_handprint"]//span[@style="display: inline;" or not(@style)]/a[@href="#"]';
  29. let moreChildrenResult = document.evaluate(moreChildrenXpath, document, null, XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
  30. let node;
  31.  
  32. while (node = moreChildrenResult.iterateNext()) {
  33. node.click();
  34. }
  35. }
  36.  
  37. function waitForBioAnchor(selector) {
  38. if (document.querySelector('a.toggle_link[id^="bio_"]')) {
  39. clickBioAnchor();
  40. } else {
  41. loopCount++;
  42.  
  43. if (loopCount <= MAX_LOOP_COUNT) {
  44. setTimeout(waitForBioAnchor, LOOP_INTERVAL);
  45. } else {
  46. console.warn("Timeout");
  47. }
  48. }
  49. }
  50.  
  51. (function () {
  52. waitForBioAnchor();
  53. clickToShowMoreChildren();
  54. })();