voe.sx Disable Popups And Purify Download Buttons

Disable popup and purify download link. Note: if the site give a "security error" page, click the shown download button again.

// ==UserScript==
// @name         voe.sx Disable Popups And Purify Download Buttons
// @namespace    https://greasyfork.org/en/users/85671-jcunews
// @version      1.0.3
// @license      AGPLv3
// @author       jcunews
// @description  Disable popup and purify download link. Note: if the site give a "security error" page, click the shown download button again.
// @match        https://voe.sx/*
// @grant        none
// @run-at       document-start
// ==/UserScript==

(() => {
  var op = window.open;
  window.open = function(u) {
    if (/robots\.txt/.test(u)) return;
    return op.apply(this)
  };
  var ael = HTMLDivElement.prototype.addEventListener;
  HTMLDivElement.prototype.addEventListener = function(typ, fn) {
    var m;
    if (this.matches && this.matches(".download-user-file") && (m = fn.toString().match(/https:\/\/voe\.sx\/dl\?op=download_orig&key=[^&]+&id=/))) {
      this.dataset.url = m[0] + location.pathname.match(/[^\/]+$/)[0];
      return
    }
    return ael.apply(this, arguments)
  };
  addEventListener("click", ev => {
    if (ev.target.matches(".download-user-file")) {
      ev.stopImmediatePropagation();
      ev.stopPropagation();
      location.href = ev.target.dataset.url
    }
  }, true)
})();