Skip to content

Instantly share code, notes, and snippets.

@Teemwu
Last active July 13, 2022 10:22
Show Gist options
  • Save Teemwu/ffa9ec6975f93cf1d9ce9ae05d28dcf6 to your computer and use it in GitHub Desktop.
Save Teemwu/ffa9ec6975f93cf1d9ce9ae05d28dcf6 to your computer and use it in GitHub Desktop.
display_all_github_issue_detail
/**
* Display all issue's detail in one page by iframe
* tips:
* 1. Disalbe 'x-frame-options' by chrome extension, you can install https://chrome.google.com/webstore/detail/ignore-x-frame-headers/gleekbfjekiniecknbkamfmkohkpodhe
* 2. Compress below code to one line by Javscript online Compressor, you can use https://jscompress.com/
* 3. Copy the compressed code and paste to chrome address bar then save as a bookmark
* 4. Open the issue list page then click that bookmark
* 5 .If you want to cancel display, retry step 4 again
*/
javascript: (function () {
const tasks = []
const items = document.querySelectorAll('.Box-row')
const observeItems = (items, observer) => items.forEach(i => observer.observe(i))
const observer = new IntersectionObserver((entries, observer) => {
if (!window.SHOW_ALL_ISSUE) return
const inViewPortItems = entries.filter(i => i.intersectionRatio > 0 && !i.target.querySelector('iframe'))
if (inViewPortItems.length <= 0) return
const item = inViewPortItems[0].target
const id = item.id
const current = tasks.findIndex(i => i.id === id)
if (current < 0) {
observer.disconnect()
tasks.push(
{
id,
handle: () => new Promise((resolve) => {
item.querySelector('div.d-flex').style.cssText = 'position: sticky !important; top: 0; z-index: 1; background-color: var(--color-canvas-subtle); box-shadow: 0 0 2px var(--color-border-default);'
const iframe = document.createElement('iframe')
iframe.style.cssText = 'width: 100%; border: none; box-sizing: border-box; padding: 0 40px; margin-top: 16px; filter: blur(50px)'
iframe.src = item.querySelector('a[id*="issue_"]').href
iframe.onload = function () {
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document
if (iframeDoc.readyState === 'complete') {
const target = iframeDoc.querySelector('.js-discussion')
if (!target) return resolve()
iframe.style.filter = 'blur(0px)'
const content = target.outerHTML
iframeDoc.body.innerHTML = content
iframeDoc.querySelector('html').style.backgroundColor = 'transparent'
iframeDoc.body.style.backgroundColor = 'transparent'
iframe.style.height = iframeDoc.documentElement.scrollHeight + 2 + 'px'
resolve()
const index = tasks.findIndex(i => i.id === id)
tasks.splice(index, 1)
observeItems(items, observer)
}
}
item.appendChild(iframe)
if (observer) observer.unobserve(item)
})
}
)
}
const run = async () => {
for (const item of tasks) {
const res = await item.handle().then()
}
}
run()
})
if (window.SHOW_ALL_ISSUE) {
items.forEach(item => {
const iframe = item.querySelector('iframe')
if (iframe) {
iframe.remove()
item.replaceWith(item.cloneNode(true))
}
window.SHOW_ALL_ISSUE = false
})
} else {
observeItems(items, observer)
window.SHOW_ALL_ISSUE = true
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment