stutrek / scrollmonitor

A simple and fast API to monitor elements as you scroll
MIT License
3.3k stars 243 forks source link

Uncaught TypeError: Cannot read properties of null (reading 'scrollHeight') #106

Open SchunckLeonardo opened 1 week ago

SchunckLeonardo commented 1 week ago

Using WXT Chrome Extension Web Framework 0.19.1, you get the following error from content.ts

Uncaught TypeError: Cannot read properties of null (reading 'scrollHeight')
    at getContentHeight (content.js:253:37)
    at new ScrollMonitorContainer2 (content.js:291:31)
    at content.js:417:23
    at content.js:4947:2
import './src/styles/skeletons.css'
import './src/styles/flags.css'

import scrollMonitor from 'scrollmonitor'

import { WebSocketModule } from './src/websocket'
import detectUrlChange from 'detect-url-change'

export default defineContentScript({
  matches: ['https://www.amazon.com/s?*'],
  runAt: 'document_start',

  async main() {
    const ws = new WebSocketModule()

    document.addEventListener('DOMContentLoaded', () => {
      ws.initWebSocket()

      const scrollWatcher = scrollMonitor.create('div[data-asin]')
      console.log(scrollWatcher)
    })

    detectUrlChange.on('change', ws.onChangedURL)
  },
})