EMCSA Plus

Enhance the Erotic Mind Control Stories Archive with some additional functionality

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name        EMCSA Plus
// @namespace   gkrishna.gent
// @match       https://mcstories.com/WhatsNew.html
// @grant       GM_getValue
// @version     0.5
// @author      Gopi Krishna
// @description Enhance the Erotic Mind Control Stories Archive with some additional functionality
// ==/UserScript==

function selectStoryByCond({authors_to_select=[]}) {
  var stories = document.getElementsByClassName("story");
  var wanted_stories = [];
  var matched_elements = [];

  storyloop: for (let story of stories) {
    subels = story.children;

    // validity check
    all_ok = true;
    if (subels.length != 3) { all_ok = false; }
    for (let se of subels) {
      if (se.nodeName != 'DIV') { all_ok = false; }
    }
    if (!all_ok) { 
      console.error("Page structure has changed, update the addon");
      return null;
    }

    author_els = subels[1].getElementsByTagName('a');
    for (let author_el of author_els) {
      for (let author of authors_to_select) {
        if (author_el.text.localeCompare(author, 'en', { sensitivity: 'base' }) == 0) {
          wanted_stories.push(story);
          matched_elements.push(author_el);
          continue storyloop;
        }
      }
    }
  }
  return [wanted_stories, matched_elements];
}


function hide_blocked_authors() {
  var authors_to_block = GM_getValue('authors_to_block', '');
  [stories_to_hide, ] = selectStoryByCond({authors_to_select: authors_to_block});
  for (let story of stories_to_hide) {
    console.log('Story '+story.children[0].children[0]+' '+
                story.children[1].textContent+' is hidden');
    story.style.display = 'none';
  }
}

function highlight_authors() {
  var authors_to_highlight = GM_getValue('authors_to_highlight', '');
  [, matched_authors] = selectStoryByCond({authors_to_select: authors_to_highlight});
  for (let author_el of matched_authors) {
    author_el.style.border = "medium solid lime";
  }
}

hide_blocked_authors();
highlight_authors();