voe.sx Disable Popups And Purify Download Buttons

.

// ==UserScript==
// @name         voe.sx Disable Popups And Purify Download Buttons
// @namespace    https://greasyfork.org/en/users/85671-jcunews
// @version      1.0.1
// @license      AGPLv3
// @author       jcunews
// @description  .
// @match        https://voe.sx/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(() => {
  addEventListener("beforescriptexecute", ev => {
    if (/var [0-9a-f]{32} = \[/i.test(ev.target.text)) ev.preventDefault()
  });
  var ael = HTMLDivElement.prototype.addEventListener;
  HTMLDivElement.prototype.addEventListener = function(typ, fn) {
    var m;
    if (this.matches(".download-user-file") && (m = fn.toString().match(/https:\/\/voe\.sx\/dl\?op=download_orig&key=[^&]+&id=/))) {
      this.onclick = () => {
        location.href = m[0] + location.pathname.match(/[^\/]+$/)[0]
      };
      return
    }
    return ael.apply(this, arguments)
  };
  addEventListener("load", () => {
    if (window.btn_download) btn_download.click()
  });
})();