[source/actions:fix] github star on non-repo pages

This commit is contained in:
Maddison Hellstrom 2020-06-19 00:29:19 -07:00
parent 6b54371781
commit 38f152aac9
1 changed files with 3 additions and 3 deletions

View File

@ -311,7 +311,7 @@ actions.gh.star = ({ toggle = false } = {}) => async () => {
const repoUrl = container.parentElement.parentElement.matches("ul.pagehead-actions")
? util.getCurrentLocation("pathname")
: new URL(container.parentElement.querySelector("a").href).pathname
: new URL(container.parentElement.querySelector("form").action).pathname
const status = container.classList.contains("on")
const repo = repoUrl.slice(1).split("/").slice(0, 2).join("/")
@ -328,9 +328,9 @@ actions.gh.star = ({ toggle = false } = {}) => async () => {
if (toggle) {
verb = "has been"
if (status) {
container.querySelector(".starred>button").click()
container.querySelector(".starred>button, button.starred").click()
} else {
container.querySelector(".unstarred>button").click()
container.querySelector(".unstarred>button, button.unstarred").click()
}
}