diff --git a/CHANGELOG.txt b/CHANGELOG.txt index b2452b9a..c7b98867 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -7,6 +7,7 @@ New features: Improvements: * Various improvements/fixes to existing rules (including Flickr, iTunes, Patreon, Soundcloud, Threads, TikTok, Tumblr) + * Improve parsing for elements Bugfixes: diff --git a/src/userscript.ts b/src/userscript.ts index 3f2aa6ab..9f3771cf 100644 --- a/src/userscript.ts +++ b/src/userscript.ts @@ -149,10 +149,10 @@ var $$IMU_EXPORT$$; // channels map: false, cache: false, - bigimage_recursive: true, + bigimage_recursive: false, input: false, check_image_get: false, - find_source: false + find_source: true }; console.log("Loaded"); @@ -21286,13 +21286,13 @@ var $$IMU_EXPORT$$; }; common_functions["_wix_bigimage_inner"] = function(src) { - var newsrc = src.replace(/(:\/\/[^/]*\/)(f\/+[-0-9a-f]{36}\/+[0-9a-z]+-[-0-9a-f]{20,}(?:\.[^/.]*)?\/+v1\/+fill\/+w_[0-9]+,h_[0-9]+)(?:,[^/]+)?(\/+.*[?&]token=.*)$/, "$1$2,q_100$3"); + var newsrc = src.replace(/(:\/\/[^/]*\/)(f\/+[-0-9a-f]{36}\/+[0-9a-z]+-[-0-9a-f]{20,}(?:\.[^/.]*)?\/+v1\/+(?:fill|fit)\/+w_[0-9]+,h_[0-9]+)(?:,[^/]+)?(\/+.*[?&]token=.*)$/, "$1$2,q_100$3"); if (newsrc !== src) { return newsrc; } // thanks to MrSeyker on greasyfork: https://greasyfork.org/en/scripts/36662-image-max-url/discussions/34976#comment-160842 - newsrc = src.replace(/(:\/\/[^/]*\/f\/+[-0-9a-f]{36}\/+[0-9a-z]+-[-0-9a-f]{20,}\.(?:png|PNG)\/+v1\/+fill\/+[^/]+\/+[^/?#]+)\.[^/.?#]+(\?.*)?$/, "$1.png$2"); + newsrc = src.replace(/(:\/\/[^/]*\/f\/+[-0-9a-f]{36}\/+[0-9a-z]+-[-0-9a-f]{20,}\.(?:png|PNG)\/+v1\/+(?:fill|fit)\/+[^/]+\/+[^/?#]+)\.[^/.?#]+(\?.*)?$/, "$1.png$2"); if (newsrc !== src) { return newsrc; } @@ -129891,6 +129891,19 @@ var $$IMU_EXPORT$$; add_bgimage(layer, el, window.getComputedStyle(el, ":after"), "after"); } + let is_sub_element = function(el, parent) { + if (el === parent) // el is not a subelement of parent + return false; + + while (el) { + if (el === parent) + return true; + el = el.parentElement; + } + + return false; + }; + for (var i = 0; i < els.length; i++) { // sidebar articles on https://www.rt.com/russia/447357-miss-moscow-2018-photos/ // the element has a size of 0, and hence isn't added to find_els_at_point @@ -129898,11 +129911,19 @@ var $$IMU_EXPORT$$; els.splice(i + 1, 0, els[i].parentElement); } - // remove every element before PICTURE as they will be added automatically anyways + // remove every sub element of PICTURE as they will be added automatically anyways // this messes up the layering - if (els[i].tagName === "PICTURE" && i == 1) { - els.splice(0, i); - i = 0; + if (els[i].tagName === "PICTURE") { + for (let j = 0; j < i; j++) { + let subel = els[j]; + + if (is_sub_element(subel, els[i])) { + els.splice(j, 1); + j--; + i--; + } + } + break; } } @@ -129914,6 +129935,7 @@ var $$IMU_EXPORT$$; if (_nir_debug_) { //console_log(els); + nir_debug("find_source", "_find_source (els)", deepcopy(els)); nir_debug("find_source", "_find_source (sources)", deepcopy(sources)); nir_debug("find_source", "_find_source (layers)", deepcopy(layers)); nir_debug("find_source", "_find_source (ok_els)", deepcopy(ok_els)); diff --git a/userscript.user.js b/userscript.user.js index 9484f77e..7b2347a9 100644 --- a/userscript.user.js +++ b/userscript.user.js @@ -138,10 +138,10 @@ var $$IMU_EXPORT$$; // channels map: false, cache: false, - bigimage_recursive: true, + bigimage_recursive: false, input: false, check_image_get: false, - find_source: false + find_source: true }; console.log("Loaded"); } @@ -19831,12 +19831,12 @@ var $$IMU_EXPORT$$; return null; }; common_functions["_wix_bigimage_inner"] = function(src) { - var newsrc = src.replace(/(:\/\/[^/]*\/)(f\/+[-0-9a-f]{36}\/+[0-9a-z]+-[-0-9a-f]{20,}(?:\.[^/.]*)?\/+v1\/+fill\/+w_[0-9]+,h_[0-9]+)(?:,[^/]+)?(\/+.*[?&]token=.*)$/, "$1$2,q_100$3"); + var newsrc = src.replace(/(:\/\/[^/]*\/)(f\/+[-0-9a-f]{36}\/+[0-9a-z]+-[-0-9a-f]{20,}(?:\.[^/.]*)?\/+v1\/+(?:fill|fit)\/+w_[0-9]+,h_[0-9]+)(?:,[^/]+)?(\/+.*[?&]token=.*)$/, "$1$2,q_100$3"); if (newsrc !== src) { return newsrc; } // thanks to MrSeyker on greasyfork: https://greasyfork.org/en/scripts/36662-image-max-url/discussions/34976#comment-160842 - newsrc = src.replace(/(:\/\/[^/]*\/f\/+[-0-9a-f]{36}\/+[0-9a-z]+-[-0-9a-f]{20,}\.(?:png|PNG)\/+v1\/+fill\/+[^/]+\/+[^/?#]+)\.[^/.?#]+(\?.*)?$/, "$1.png$2"); + newsrc = src.replace(/(:\/\/[^/]*\/f\/+[-0-9a-f]{36}\/+[0-9a-z]+-[-0-9a-f]{20,}\.(?:png|PNG)\/+v1\/+(?:fill|fit)\/+[^/]+\/+[^/?#]+)\.[^/.?#]+(\?.*)?$/, "$1.png$2"); if (newsrc !== src) { return newsrc; } @@ -115452,17 +115452,33 @@ var $$IMU_EXPORT$$; add_bgimage(layer, el, window.getComputedStyle(el, ":before"), "before"); add_bgimage(layer, el, window.getComputedStyle(el, ":after"), "after"); } + var is_sub_element = function(el, parent) { + if (el === parent) // el is not a subelement of parent + return false; + while (el) { + if (el === parent) + return true; + el = el.parentElement; + } + return false; + }; for (var i = 0; i < els.length; i++) { // sidebar articles on https://www.rt.com/russia/447357-miss-moscow-2018-photos/ // the element has a size of 0, and hence isn't added to find_els_at_point if (els[i].tagName === "IMG" && els[i].parentElement && els[i].parentElement.tagName === "PICTURE" && array_indexof(els, els[i].parentElement) < 0) { els.splice(i + 1, 0, els[i].parentElement); } - // remove every element before PICTURE as they will be added automatically anyways + // remove every sub element of PICTURE as they will be added automatically anyways // this messes up the layering - if (els[i].tagName === "PICTURE" && i == 1) { - els.splice(0, i); - i = 0; + if (els[i].tagName === "PICTURE") { + for (var j_1 = 0; j_1 < i; j_1++) { + var subel = els[j_1]; + if (is_sub_element(subel, els[i])) { + els.splice(j_1, 1); + j_1--; + i--; + } + } break; } } @@ -115472,6 +115488,7 @@ var $$IMU_EXPORT$$; } if (_nir_debug_) { //console_log(els); + nir_debug("find_source", "_find_source (els)", deepcopy(els)); nir_debug("find_source", "_find_source (sources)", deepcopy(sources)); nir_debug("find_source", "_find_source (layers)", deepcopy(layers)); nir_debug("find_source", "_find_source (ok_els)", deepcopy(ok_els)); @@ -116018,8 +116035,8 @@ var $$IMU_EXPORT$$; } } var newels = find_els_at_point(xy, options, newchildren, prev, zoom_cache); - for (var j_1 = 0; j_1 < newels.length; j_1++) { - var newel = newels[j_1]; + for (var j_2 = 0; j_2 < newels.length; j_2++) { + var newel = newels[j_2]; //console_log("about to add", newel, deepcopy(ret)) if (array_indexof(ret, newel) < 0) { //console_log("adding", newel);