Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@razonyang
Copy link

Fixed #850

@vercel
Copy link

vercel bot commented Jan 13, 2023

@razonyang is attempting to deploy a commit to the giscus Team on Vercel.

A member of the Team first needs to authorize it.

@lukethacoder
Copy link

Keen to see this one merged in

Copy link
Member

@laymonage laymonage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but inline scripts are a bad idea for security and other reasons. I'd much rather dispatch a custom Event that your code can listen to.

@laymonage laymonage closed this Dec 31, 2024
@YexuanXiao
Copy link
Contributor

@laymonage Can a message be sent to the parent window after gitcus is successfully loaded? This is a useful feature.

@YexuanXiao
Copy link
Contributor

YexuanXiao commented Apr 14, 2025

I use the following code to detect if giscus is loaded:

const element = document.querySelector('div.giscus')
const observer = new MutationObserver((mutationsList, observer) => {
    for (const record of mutationsList) {
        if (record.type !== 'childList') continue
        const iframe = record.addedNodes[0];
        iframe.addEventListener('load', () => {
            changeTheme()
            // and event bingdings here
        })
        observer.disconnect()
    }
})
observer.observe(element, { childList: true, subtree: true, attributes: true })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to aware the comments <iframe> was loaded?

5 participants