asterleen / Ask.fm Sanitizer

// ==UserScript==
// @name         Ask.fm Sanitizer
// @namespace    https://asterleen.com
// @version      0.2.3
// @description  ask devs plz go fuck urselves with this shit
// @author       Asterleen
// @match        https://ask.fm/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function () {
  'use strict';

  function removePopularShit() {
    var shit = document.getElementsByClassName('streamItem_origin-promoted');

    if (shit && shit.length > 0) {
      console.log('ASKSanitizer: removing ' + shit.length + ' blocks of popular shit');
      shit[0].parentNode.remove();
    }

  }

  function switchToNormalField() {
    var fuckingBackgroundedForms = document.getElementsByClassName('answer cardComposer');

    if (fuckingBackgroundedForms && fuckingBackgroundedForms.length > 0) {
      var closeButtons = document.getElementsByClassName('icon-close');

      for (var i = 0; i < closeButtons.length; i++) {
        var currentCloseButton = closeButtons[i];

        if (currentCloseButton.getAttribute("data-action") === "AnswerCardClose") { // search for exactly the button that closes the fucking card answer
          currentCloseButton.dispatchEvent(new MouseEvent("click", { // close that annoying shit
            'view': window,
            'bubbles': true,
            'cancelable': true
          }));
        }
      }
    }

  }

  function sanitizeAskFm() {
    removePopularShit();
    switchToNormalField();
  }

  var observer = new MutationObserver(sanitizeAskFm);

  observer.observe(document, {
    childList: true,
    subtree: true,
    attributes: false,
    characterData: false
  });

  sanitizeAskFm();

})();