diff --git a/src/userscript.ts b/src/userscript.ts index 8fd9997c..302745bd 100644 --- a/src/userscript.ts +++ b/src/userscript.ts @@ -115055,6 +115055,26 @@ var $$IMU_EXPORT$$; } } + if (host_domain_nosub === "cnn.com") { + return { + element_ok: function(el) { + if (el.tagName.toUpperCase() === "BUTTON" && ( + el.classList.contains("gallery-inline__next-overlay") || + el.classList.contains("gallery-inline__prev-overlay") + )) { + let parent = el.parentElement; + if (parent.classList.contains("gallery-inline__container")) { + let slides = parent.querySelector(".gallery-inline__slides"); + return { + el: slides, + search: true + }; + } + } + } + } + } + return null; }; @@ -125954,7 +125974,8 @@ var $$IMU_EXPORT$$; } type FindSourceOptions = { - links?:boolean + links?:boolean, + point?:[number, number] }; function find_source(els:Array, options?:FindSourceOptions) { if (!options) options = {}; @@ -126222,7 +126243,7 @@ var $$IMU_EXPORT$$; return true; } - function addTagElement(el, layer) { + function addTagElement(el, layer:number) { //nir_debug("find_source", "addTagElement", el); if (helpers && helpers.element_replace) { @@ -126245,13 +126266,37 @@ var $$IMU_EXPORT$$; if (element_ok_result === true) { ok_els.push(ok_el_obj); set_add(ok_els_set, el); - } else { - if (is_element(element_ok_result)) { - ok_el_obj.el = element_ok_result; - ok_els.push(ok_el_obj); - set_add(ok_els_set, el); + } else if (typeof element_ok_result === "object") { + if (is_element(element_ok_result)) + element_ok_result = {el: element_ok_result}; + + ok_el_obj.el = element_ok_result.el; + ok_els.push(ok_el_obj); + set_add(ok_els_set, el); - el = element_ok_result; + el = element_ok_result.el; + + if (element_ok_result.search) { + let point = options.point; + if (!point) { + let rect = get_bounding_client_rect(el); + point = [ + rect.left + (rect.width / 2), + rect.top + (rect.height / 2) + ]; + } + + let found_els = find_els_at_point(point, { + els_mode: "full", + els: [el] + }); + + for (let fel of found_els) { + if (fel === el) + continue; + + addElement(fel); + } } } } @@ -127325,11 +127370,24 @@ var $$IMU_EXPORT$$; } var exclude_find_els = new_set(); - function find_els_at_point(xy, els?:Array, prev?:IMUSet, zoom_cache?:Map):Array { + type FindElsAtPointOptions = { + els_mode?: "full"|"hybrid"|"simple", + els?: Array + } + function find_els_at_point(xy, options?:FindElsAtPointOptions, els?:Array, prev?:IMUSet, zoom_cache?:Map):Array { // test for pointer-events: none: https://www.shacknews.com/article/114834/should-you-choose-vulkan-or-directx-12-in-red-dead-redemption-2 if (false && _nir_debug_) - console_log("find_els_at_point", deepcopy(xy), deepcopy(els), deepcopy(prev)); + console_log("find_els_at_point", deepcopy(options), deepcopy(xy), deepcopy(els), deepcopy(prev)); + + if (!options) { + options = {}; + } + + if (!options.els_mode) + options.els_mode = get_single_setting("mouseover_find_els_mode"); + if (options.els && !els) + els = options.els; var first_run = false; if (!prev) { @@ -127348,8 +127406,6 @@ var $$IMU_EXPORT$$; var ret = []; var afterret = []; - var els_mode = get_single_setting("mouseover_find_els_mode"); - if (!els) { let orig_els = document.elementsFromPoint(xy[0], xy[1]); @@ -127365,26 +127421,26 @@ var $$IMU_EXPORT$$; console_log("find_els_at_point (elsfrompoint)", deepcopy(els)); } - if (els_mode === "simple") + if (options.els_mode === "simple") return els as Array; } - for (var i = 0; i < els.length; i++) { - if (i > 0 && first_run && els_mode === "hybrid") { + for (let i = 0; i < els.length; i++) { + if (i > 0 && first_run && options.els_mode === "hybrid") { ret.push(els[i]); continue; } - var el = els[i]; + let el = els[i]; if (set_has(prev, el)) continue; set_add(prev, el); - var el_has_children = false; - var el_children = null; - var el_shadow_children = null; + let el_has_children = false; + let el_children = null; + let el_shadow_children = null; if (el.childElementCount > 0) { el_children = el.children; @@ -127416,9 +127472,9 @@ var $$IMU_EXPORT$$; } } - var newels = find_els_at_point(xy, newchildren, prev, zoom_cache); - for (var j = 0; j < newels.length; j++) { - var newel = newels[j]; + let newels = find_els_at_point(xy, options, newchildren, prev, zoom_cache); + for (let j = 0; j < newels.length; j++) { + let newel = newels[j]; //console_log("about to add", newel, deepcopy(ret)) if (array_indexof(ret, newel) < 0) { //console_log("adding", newel); @@ -127429,7 +127485,7 @@ var $$IMU_EXPORT$$; // youtube links on: https://old.reddit.com/r/anime/comments/btlmky/wt_mushishi_a_beautifully_melancholic_take_on_the/ // they pop up outside of the cursor - var rect = get_bounding_client_rect(el, zoom_cache); + let rect = get_bounding_client_rect(el, zoom_cache); if (rect && rect.width > 0 && rect.height > 0 && rect.left <= xy[0] && rect.right >= xy[0] && rect.top <= xy[1] && rect.bottom >= xy[1] && @@ -127438,7 +127494,7 @@ var $$IMU_EXPORT$$; } } - for (var i = 0; i < afterret.length; i++) { + for (let i = 0; i < afterret.length; i++) { if (array_indexof(ret, afterret[i]) < 0) ret.push(afterret[i]); } @@ -127447,7 +127503,7 @@ var $$IMU_EXPORT$$; console_log("find_els_at_point (unsorted ret)", shallowcopy(ret)); } - if (first_run && els_mode === "hybrid") { + if (first_run && options.els_mode === "hybrid") { return ret; } @@ -127570,7 +127626,7 @@ var $$IMU_EXPORT$$; mouseContextY = null; } - var source = find_source(els); + var source = find_source(els, {point: point}); if (!source && settings.mouseover_allow_self_pagelink && popup_trigger_reason === "keyboard") { source = { @@ -129027,8 +129083,9 @@ var $$IMU_EXPORT$$; e.stopImmediatePropagation(); e.stopPropagation(); - var els = find_els_at_point([mouseX, mouseY]); - var source = find_source(els); + let point = [mouseX, mouseY]; + var els = find_els_at_point(point); + var source = find_source(els, {point: point}); if (!source || !source.el) return; diff --git a/userscript.user.js b/userscript.user.js index e14cbac0..7c1b168d 100644 --- a/userscript.user.js +++ b/userscript.user.js @@ -103087,6 +103087,23 @@ var $$IMU_EXPORT$$; } }; } + if (host_domain_nosub === "cnn.com") { + return { + element_ok: function(el) { + if (el.tagName.toUpperCase() === "BUTTON" && (el.classList.contains("gallery-inline__next-overlay") || + el.classList.contains("gallery-inline__prev-overlay"))) { + var parent_6 = el.parentElement; + if (parent_6.classList.contains("gallery-inline__container")) { + var slides = parent_6.querySelector(".gallery-inline__slides"); + return { + el: slides, + search: true + }; + } + } + } + }; + } return null; }; var _get_album_info_gallery = function(album_info, el, nextprev) { @@ -112182,12 +112199,32 @@ var $$IMU_EXPORT$$; if (element_ok_result === true) { ok_els.push(ok_el_obj); set_add(ok_els_set, el); - } else { - if (is_element(element_ok_result)) { - ok_el_obj.el = element_ok_result; - ok_els.push(ok_el_obj); - set_add(ok_els_set, el); - el = element_ok_result; + } else if (typeof element_ok_result === "object") { + if (is_element(element_ok_result)) + element_ok_result = { el: element_ok_result }; + ok_el_obj.el = element_ok_result.el; + ok_els.push(ok_el_obj); + set_add(ok_els_set, el); + el = element_ok_result.el; + if (element_ok_result.search) { + var point = options.point; + if (!point) { + var rect = get_bounding_client_rect(el); + point = [ + rect.left + (rect.width / 2), + rect.top + (rect.height / 2) + ]; + } + var found_els = find_els_at_point(point, { + els_mode: "full", + els: [el] + }); + for (var _i = 0, found_els_1 = found_els; _i < found_els_1.length; _i++) { + var fel = found_els_1[_i]; + if (fel === el) + continue; + addElement(fel); + } } } } @@ -113046,10 +113083,17 @@ var $$IMU_EXPORT$$; currenttab_is_image() && !imagetab_ok_override; } var exclude_find_els = new_set(); - function find_els_at_point(xy, els, prev, zoom_cache) { + function find_els_at_point(xy, options, els, prev, zoom_cache) { // test for pointer-events: none: https://www.shacknews.com/article/114834/should-you-choose-vulkan-or-directx-12-in-red-dead-redemption-2 if (false && _nir_debug_) - console_log("find_els_at_point", deepcopy(xy), deepcopy(els), deepcopy(prev)); + console_log("find_els_at_point", deepcopy(options), deepcopy(xy), deepcopy(els), deepcopy(prev)); + if (!options) { + options = {}; + } + if (!options.els_mode) + options.els_mode = get_single_setting("mouseover_find_els_mode"); + if (options.els && !els) + els = options.els; var first_run = false; if (!prev) { prev = new_set(); @@ -113064,24 +113108,23 @@ var $$IMU_EXPORT$$; } var ret = []; var afterret = []; - var els_mode = get_single_setting("mouseover_find_els_mode"); if (!els) { var orig_els = document.elementsFromPoint(xy[0], xy[1]); els = []; for (var _i = 0, orig_els_1 = orig_els; _i < orig_els_1.length; _i++) { - var el_2 = orig_els_1[_i]; - if (!set_has(exclude_find_els, el_2)) - els.push(el_2); + var el = orig_els_1[_i]; + if (!set_has(exclude_find_els, el)) + els.push(el); } afterret = els; if (_nir_debug_) { console_log("find_els_at_point (elsfrompoint)", deepcopy(els)); } - if (els_mode === "simple") + if (options.els_mode === "simple") return els; } for (var i = 0; i < els.length; i++) { - if (i > 0 && first_run && els_mode === "hybrid") { + if (i > 0 && first_run && options.els_mode === "hybrid") { ret.push(els[i]); continue; } @@ -113117,9 +113160,9 @@ var $$IMU_EXPORT$$; newchildren.push(el_shadow_children[j]); } } - var newels = find_els_at_point(xy, newchildren, prev, zoom_cache); - for (var j = 0; j < newels.length; j++) { - var newel = newels[j]; + 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]; //console_log("about to add", newel, deepcopy(ret)) if (array_indexof(ret, newel) < 0) { //console_log("adding", newel); @@ -113144,7 +113187,7 @@ var $$IMU_EXPORT$$; if (_nir_debug_ && ret.length > 0) { console_log("find_els_at_point (unsorted ret)", shallowcopy(ret)); } - if (first_run && els_mode === "hybrid") { + if (first_run && options.els_mode === "hybrid") { return ret; } var get_zindex_raw = function(el) { @@ -113241,7 +113284,7 @@ var $$IMU_EXPORT$$; mouseContextX = null; mouseContextY = null; } - var source = find_source(els); + var source = find_source(els, { point: point }); if (!source && settings.mouseover_allow_self_pagelink && popup_trigger_reason === "keyboard") { source = { el: document.body, @@ -114424,8 +114467,9 @@ var $$IMU_EXPORT$$; e.preventDefault(); e.stopImmediatePropagation(); e.stopPropagation(); - var els = find_els_at_point([mouseX, mouseY]); - var source = find_source(els); + var point = [mouseX, mouseY]; + var els = find_els_at_point(point); + var source = find_source(els, { point: point }); if (!source || !source.el) return; source = add_source(source);