PageSourceSearch

https://lcc-merican.de/modal-scroll-patch.js

js lcc-merican.de collected 2026-10-09 23:24:27 UTC 1,229 bytes, 53 lines download raw bytes

1// eslint-disable-next-line no-extra-semi
2;(function () {
3  if (typeof window === 'undefined') {
4    return
5  }
6
7  // detect iframe safely
8  let isInIframe = false
9  try {
10    isInIframe = window.self !== window.top
11  } catch {
12    isInIframe = true
13  }
14
15  // only apply in iframe
16  if (!isInIframe) {
17    return
18  }
19
20  if (window.__modalScrollPatchApplied) {
21    return
22  }
23  window.__modalScrollPatchApplied = true
24
25  const origFocus = HTMLElement.prototype.focus
26  HTMLElement.prototype.focus = function (options) {
27    if (options === null || typeof options !== 'object') {
28      return origFocus.call(this, { preventScroll: true })
29    }
30    return origFocus.call(this, {
31      ...options,
32      preventScroll: true,
33    })
34  }
35
36  const origScrollIntoView = Element.prototype.scrollIntoView
37  Element.prototype.scrollIntoView = function (arg) {
38    if (arg == null || typeof arg !== 'object') {
39      return origScrollIntoView.call(this, {
40        block: 'nearest',
41        inline: 'nearest',
42        behavior: 'auto',
43      })
44    }
45
46    return origScrollIntoView.call(this, {
47      ...arg,
48      block: arg.block ?? 'nearest',
49      inline: arg.inline ?? 'nearest',
50      behavior: arg.behavior ?? 'auto',
51    })
52  }
53})()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.