Skip to content

Commit

Permalink
feat(github): add support for new issues panel
Browse files Browse the repository at this point in the history
  • Loading branch information
askides committed Nov 22, 2024
1 parent 37d87a9 commit b411281
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/content/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,53 @@ togglbutton.render(
},
)

// Issue Beta
togglbutton.render(
'[data-testid="issue-viewer-metadata-pane"]',
{ observe: true },
function (elem) {
const titleElem = $('[data-testid="issue-title"]')
const projectElem = $('[data-testid="project-title"]')
const existingTag = $('.discussion-sidebar-item.toggl')

const numElem = titleElem.parentElement.querySelector('span')

if (existingTag) {
if (existingTag.parentNode.firstChild.classList.contains('toggl')) {
return
}
existingTag.parentNode.removeChild(existingTag)
}

let description = titleElem.textContent

if (numElem !== null) {
description = numElem.textContent + ' ' + description.trim()
}

const elementOfBase = document.querySelector(
'[data-testid="sidebar-section"]',
)

const div = document.createElement('div')
div.className = elementOfBase.className
div.classList.add('discussion-sidebar-item', 'toggl')
div.style.paddingLeft = '8px'
div.style.paddingRight = '8px'

console.log(projectElem?.textContent)

const link = togglbutton.createTimerLink({
className: 'github',
description: description,
projectName: projectElem && projectElem.textContent,
})

div.appendChild(link)
elem.prepend(div)
},
)

// Project Page side pane
togglbutton.render(
'div[role="dialog"]:not(.toggl)',
Expand Down

0 comments on commit b411281

Please sign in to comment.