Add goodreads and amazon author name selectors

This commit is contained in:
Hezekiah Michael 2022-07-18 03:22:32 -04:00
parent ed4d6ab5aa
commit ac484c8b54

View File

@ -31,7 +31,7 @@ function fixupSiteStyles() {
.assigned-label-transphobic { outline: 2px solid var(--ShinigamiEyesTransphobic) !important; }
.assigned-label-t-friendly { outline: 1px solid var(--ShinigamiEyesTFriendly) !important; }
`);
} else if (hostname == 'rationalwiki.org' || domainIs(hostname, 'wikipedia.org')) {
} else if (hostname == 'rationalwiki.org' || domainIs(hostname, 'wikipedia.org') || hostname == 'amazon.com' || hostname == 'goodreads.com') {
addStyleSheet(`
.assigned-label-transphobic { outline: 1px solid var(--ShinigamiEyesTransphobic) !important; }
.assigned-label-t-friendly { outline: 1px solid var(--ShinigamiEyesTFriendly) !important; }
@ -430,10 +430,19 @@ function getIdentifierFromElementImpl(element: HTMLAnchorElement, originalTarget
}
} else if (domainIs(hostname, 'wikipedia.org')) {
if (element.classList.contains('interlanguage-link-target')) return null;
} else if (hostname == 'goodreads.com') {
if (element.classList.contains('authorName')) return element.textContent;
if (element.classList.contains('author')) return element.textContent;
if (element.classList.contains('gr-book__authorLink')) return element.textContent;
} else if (hostname == 'amazon.com') {
if (element.classList.contains('contributorNameID')) return element.textContent;
if (element.classList.contains('._cDEzb_p13n-sc-css-line-clamp-1_2o7X6')) return element.textContent;
}
if (element.classList.contains('tumblelog')) return element.textContent.replace('@', '') + '.tumblr.com';
const href = element.href;
if (href && (!href.endsWith('#') || href.includes('&stick='))) return getIdentifierFromURLImpl(tryParseURL(href));
return null;