Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaScript error in "AdGuard Extra.user.js" in older browsers versions #4

Closed
ameshkov opened this issue Jun 20, 2019 · 2 comments
Closed
Assignees

Comments

@ameshkov
Copy link
Member

@victor-homyakov commented on Wed Jun 19 2019

Steps to reproduce

  1. Install older version of Chrome (53 and older) or Opera (40 and older)
  2. Install AdGuard with AdGuard Extra script
  3. Open yandex.ru

Expected behavior

No errors should happen

Actual behavior

Older browsers (Opera 40 and older, Chrome 53 and older) will throw JavaScript error

TypeError: Object.values is not a function
    at findAds (AdGuard%20Extra.user.js:71:7335)
    at hideYaDirectAds (AdGuard%20Extra.user.js:71:7938)
    at MutationObserver.eval (AdGuard%20Extra.user.js:71:8766)

because JavaScript in AdGuard Extra.user.js uses Object.values(), which isn't supported in older browser versions https://caniuse.com/#search=Object.values.

Your environment

  • AdGuard AdBlocker extension version:
  • Environment name and version: Chrome/53.0.2785.21
  • Filters you use in AdGuard:
  • Any other browser extensions you have installed: none
@victor-homyakov
Copy link

Also script https://userscripts.adtidy.org/beta/adguard-extra/1.0/adguard-extra.user.js contains the same function repeated five times with different names:

    function d(e) {
        return function(e) {
            if (Array.isArray(e)) {
                for (var t = 0, n = new Array(e.length); t < e.length; t++) n[t] = e[t];
                return n
            }
        }(e) || function(e) {
            if (Symbol.iterator in Object(e) || "[object Arguments]" === Object.prototype.toString.call(e)) return Array.from(e)
        }(e) || function() {
            throw new TypeError("Invalid attempt to spread non-iterable instance")
        }()
    }

...

    function g(e) {
        return function(e) {
            if (Array.isArray(e)) {
                for (var t = 0, n = new Array(e.length); t < e.length; t++) n[t] = e[t];
                return n
            }
        }(e) || function(e) {
            if (Symbol.iterator in Object(e) || "[object Arguments]" === Object.prototype.toString.call(e)) return Array.from(e)
        }(e) || function() {
            throw new TypeError("Invalid attempt to spread non-iterable instance")
        }()
    }

...

    function m(e) {
        return function(e) {
            if (Array.isArray(e)) {
                for (var t = 0, n = new Array(e.length); t < e.length; t++) n[t] = e[t];
                return n
            }
        }(e) || function(e) {
            if (Symbol.iterator in Object(e) || "[object Arguments]" === Object.prototype.toString.call(e)) return Array.from(e)
        }(e) || function() {
            throw new TypeError("Invalid attempt to spread non-iterable instance")
        }()
    }

...

    function w(e) {
        return function(e) {
            if (Array.isArray(e)) {
                for (var t = 0, n = new Array(e.length); t < e.length; t++) n[t] = e[t];
                return n
            }
        }(e) || function(e) {
            if (Symbol.iterator in Object(e) || "[object Arguments]" === Object.prototype.toString.call(e)) return Array.from(e)
        }(e) || function() {
            throw new TypeError("Invalid attempt to spread non-iterable instance")
        }()
    }

    function S(e) {
        return function(e) {
            if (Array.isArray(e)) {
                for (var t = 0, n = new Array(e.length); t < e.length; t++) n[t] = e[t];
                return n
            }
        }(e) || function(e) {
            if (Symbol.iterator in Object(e) || "[object Arguments]" === Object.prototype.toString.call(e)) return Array.from(e)
        }(e) || function() {
            throw new TypeError("Invalid attempt to spread non-iterable instance")
        }()
    }

Looks like a new function is inserted for each transpiled spread operator. In any case there is an opportunity for improvement.

@ameshkov
Copy link
Member Author

Yeah, we don't use plugin-transform-runtime as it tends to pollute global scope even when corejs 3 is enabled. Anyways, we can improve the build process to avoid duplications, thanks for reporting it!

@adguard-bot adguard-bot changed the title JavaScript error in "AdGuard Extra.user.js": Uncaught TypeError: Object.values is not a function JavaScript error in "AdGuard Extra.user.js" in older browsers Feb 6, 2020
@adguard-bot adguard-bot changed the title JavaScript error in "AdGuard Extra.user.js" in older browsers JavaScript error in "AdGuard Extra.user.js" in older browsers versions Feb 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants