Extend addEventListenerDefuser to support defusing based on the element (original) (raw)

Prerequisites

I tried to reproduce the issue when...

Description

Go to:
https://subkade.ir/%D8%AF%D8%A7%D9%86%D9%84%D9%88%D8%AF-%D8%B2%DB%8C%D8%B1%D9%86%D9%88%DB%8C%D8%B3-%D8%B3%D8%B1%DB%8C%D8%A7%D9%84-prison-break/

Click on "دانلود زیرنویس" (##a.indirect), you'll get another page where you have to click on "برای ادامه اینجا کلیک کنید" (##a.sk-dl), then you'll get a 6 seconds timer to download the subtitles.

The main download link looks like this:

دانلود

Add this to fix the link:

subkade.ir##+js(set-attr, a.indirect[data-get], href, [data-get])

The download link is still not working, because of the following "click" event listener:
image

Add this to fix it:

subkade.ir##+js(aeld, click, return"undefined")

The download link is working, but now the "زیرنویس انگلیسی" (##.lock.sk-download-list) section is broken because it used the same "click" event listener.

Solution:

// ==UserScript== // @name Subkade.ir // @namespace Violentmonkey Scripts // @match http://.subkade.ir/ // @match https://.subkade.ir/ // @grant none // @author PersianBlocker // @run-at document-start // ==/UserScript==

(function() { 'use strict';

self.EventTarget.prototype.addEventListener = new Proxy(self.EventTarget.prototype.addEventListener, { apply(target, thisArg, args) { const node = thisArg; if (args[0] === 'click' && node.nodeName === 'A' && node.className && node.className === 'indirect') { if (args[1].toString().includes('return"undefined"') === true) { return; } }; return Reflect.apply(target, thisArg, args); } })

}) ();

Maybe add a forth optional positional argument?

subkade.ir##+js(aeld, click, return"undefined", a.indirect)