Skip to content

Extend addEventListenerDefuser to support defusing based on the element #3061

Closed
@MasterKia

Description

@MasterKia

Prerequisites

  • I verified that this is not a filter list issue. Report any issues with filter lists or broken website functionality in the uAssets issue tracker.
  • This is NOT an issue with YouTube, Facebook or Twitch.
  • This is not a support issue or a question. For support, questions, or help, visit /r/uBlockOrigin.
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • The issue is not present after disabling uBO in the browser.
  • I checked the documentation to understand that the issue I am reporting is not normal behavior.

I tried to reproduce the issue when...

  • uBO is the only extension.
  • uBO uses default lists and settings.
  • using a new, unmodified browser profile.

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:

<a data-get="https://dl1.subkade.ir/wp-content/uploads/2019/07/Prison-Break-S01-Complete.zip" target="_self" oncontextmenu="return false;" class="indirect">دانلود</a>

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestfixedissue has been addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions