EMCSA Plus

Enhance the Erotic Mind Control Stories Archive with some additional functionality

  1. // ==UserScript==
  2. // @name EMCSA Plus
  3. // @namespace gkrishna.gent
  4. // @match https://mcstories.com/WhatsNew.html
  5. // @grant GM_getValue
  6. // @version 0.5
  7. // @author Gopi Krishna
  8. // @description Enhance the Erotic Mind Control Stories Archive with some additional functionality
  9. // ==/UserScript==
  10.  
  11. function selectStoryByCond({authors_to_select=[]}) {
  12. var stories = document.getElementsByClassName("story");
  13. var wanted_stories = [];
  14. var matched_elements = [];
  15.  
  16. storyloop: for (let story of stories) {
  17. subels = story.children;
  18.  
  19. // validity check
  20. all_ok = true;
  21. if (subels.length != 3) { all_ok = false; }
  22. for (let se of subels) {
  23. if (se.nodeName != 'DIV') { all_ok = false; }
  24. }
  25. if (!all_ok) {
  26. console.error("Page structure has changed, update the addon");
  27. return null;
  28. }
  29.  
  30. author_els = subels[1].getElementsByTagName('a');
  31. for (let author_el of author_els) {
  32. for (let author of authors_to_select) {
  33. if (author_el.text.localeCompare(author, 'en', { sensitivity: 'base' }) == 0) {
  34. wanted_stories.push(story);
  35. matched_elements.push(author_el);
  36. continue storyloop;
  37. }
  38. }
  39. }
  40. }
  41. return [wanted_stories, matched_elements];
  42. }
  43.  
  44.  
  45. function hide_blocked_authors() {
  46. var authors_to_block = GM_getValue('authors_to_block', '');
  47. [stories_to_hide, ] = selectStoryByCond({authors_to_select: authors_to_block});
  48. for (let story of stories_to_hide) {
  49. console.log('Story '+story.children[0].children[0]+' '+
  50. story.children[1].textContent+' is hidden');
  51. story.style.display = 'none';
  52. }
  53. }
  54.  
  55. function highlight_authors() {
  56. var authors_to_highlight = GM_getValue('authors_to_highlight', '');
  57. [, matched_authors] = selectStoryByCond({authors_to_select: authors_to_highlight});
  58. for (let author_el of matched_authors) {
  59. author_el.style.border = "medium solid lime";
  60. }
  61. }
  62.  
  63. hide_blocked_authors();
  64. highlight_authors();