AdguardTeam / CoreLibs

Core Adguard libraries
https://adguard.com/
Apache License 2.0
39 stars 7 forks source link

AdGuard breaks HandyImage userscript [Usercripts] #1858

Closed Alex-302 closed 5 months ago

Alex-302 commented 7 months ago

More info about the problem: https://github.com/Owyn/HandyImage/commit/67da999d3f7ce4f90e88a559902ce75230e2ef85

Homepage: https://github.com/Owyn/HandyImage/

AdGuard for Windows 7.16

Alex-302 commented 7 months ago

Probably related to this issue https://github.com/AdguardTeam/AdguardFilters/issues/171477#issue-2099927946

User's usercsipts https://adsbypasser.github.io/releases/adsbypasser.lite.es7.user.js https://gist.github.com/TheJzoli/8a4cd979d433b7359cdf61c238bc0181/raw/sb.ltn.fi.hidecolumns.user.js https://github.com/chocolateboy/userscripts/raw/master/src/imdb-tomatoes.user.js https://github.com/FarisHijazi/Rarbg-Enhancer-UserScript/raw/master/Rarbg-Enhancer-UserScript.user.js https://github.com/noCaptchaAi/hCaptchaSolver.user.js/raw/main/hCaptchaSolver.user.js https://github.com/Owyn/HandyImage/raw/master/HandyImage.user.js https://github.com/XIU2/UserScript/raw/master/Autopage.user.js https://update.greasyfork.org/scripts/14085/kinozaltv%20magnet%20links.user.js https://update.greasyfork.org/scripts/23772/Absolute%20Enable%20Right%20Click%20%20Copy.user.js https://update.greasyfork.org/scripts/24204/Picviewer%20CE%2B.user.js https://update.greasyfork.org/scripts/31088/MoreCAPTCHA.user.js https://update.greasyfork.org/scripts/32939/no%20captcha.user.js https://update.greasyfork.org/scripts/386590/JPS%20Random%20Torrent%20Button.user.js https://update.greasyfork.org/scripts/401432/Google%20Image%20Search%20-%20Show%20Image%20Dimensions.user.js https://update.greasyfork.org/scripts/421603/Magic%20Userscript%2B%20%3A%20Show%20Site%20All%20UserJS.user.js https://update.greasyfork.org/scripts/431691/Bypass%20All%20Shortlinks.user.js https://update.greasyfork.org/scripts/438684/Pagetual.user.js https://update.greasyfork.org/scripts/439388/Auto%20Click%20Captcha.user.js https://update.greasyfork.org/scripts/455610/AUTO-OPEN%20hCaptcha%20%2B%20reCaptcha.user.js https://update.greasyfork.org/scripts/464785/Autopass%20Cloudflare%20CAPTCHA.user.js https://userscripts.adtidy.org/beta/assistant/4.3/assistant.user.js https://userscripts.adtidy.org/beta/popup-blocker/2.5/popupblocker.user.js https://userscripts.adtidy.org/release/disable-amp/1.0/disable-amp.user.js
slavaleleka commented 5 months ago

there are few issue with the userscript:

  1. async loadCfg should be called as await loadCfg()https://github.com/Owyn/HandyImage/blob/2d64feeffd50ae54b9c3c7dfb74d80c46589b7d9/HandyImage.user.js#L3679 — otherwise the config is not loaded before the first makeimage() call. that's why it's first call logs waiting for settings to load to makeimage() because cfg_js is undefined yet, so setTimeout callback should be executed.
  2. but because of window.stop(); the image is not displayed after that.
Owyn commented 5 months ago
  1. async loadCfg should be called as await loadCfg()

that would defeat the whole purpose of the async function and make script stop and (a)wait for the result of the function making it synchronous which is not the goal there изображение

2 window.stop();

it's executed before the image is added to the page so it shouldn't (doesn't for me and my tests) interfere with the image loading

but thank you for looking closer at the script and providing feedback 👍🏻

anyway, this has nothing to do with the issue of GM_functions being of object type in Adguard which was the reason it was breaking the userscript in that version ( https://github.com/Owyn/HandyImage/commit/67da999d3f7ce4f90e88a559902ce75230e2ef85#commitcomment-138183516 )

most scripts writers compare GM_functions with a falsy check with ! before using em which'd fail here since object is not falsy at all, why would you do that?