Support for Medium and Disqus
This commit is contained in:
parent
3a59cbc832
commit
927c67a993
@ -79,7 +79,9 @@ function createContextMenu(text, id) {
|
|||||||
"*://*.facebook.com/*",
|
"*://*.facebook.com/*",
|
||||||
"*://*.youtube.com/*",
|
"*://*.youtube.com/*",
|
||||||
"*://*.reddit.com/*",
|
"*://*.reddit.com/*",
|
||||||
"*://*.twitter.com/*"
|
"*://*.twitter.com/*",
|
||||||
|
"*://medium.com/*",
|
||||||
|
"*://disqus.com/*"
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -6,70 +6,100 @@ if (hostname.startsWith('www.')) {
|
|||||||
}
|
}
|
||||||
if (hostname.endsWith('.reddit.com')) hostname = 'reddit.com';
|
if (hostname.endsWith('.reddit.com')) hostname = 'reddit.com';
|
||||||
|
|
||||||
|
|
||||||
var myself = null;
|
var myself = null;
|
||||||
if (hostname == 'reddit.com') {
|
|
||||||
myself = document.querySelector('#header-bottom-right .user a');
|
function fixupSiteStyles(){
|
||||||
if (!myself) {
|
if (hostname == 'reddit.com') {
|
||||||
var m = document.querySelector('#USER_DROPDOWN_ID');
|
myself = document.querySelector('#header-bottom-right .user a');
|
||||||
if (m) {
|
if (!myself) {
|
||||||
m = [...m.querySelectorAll('*')].filter(x => x.childNodes.length == 1 && x.firstChild.nodeType == 3).map(x => x.textContent)[0]
|
var m = document.querySelector('#USER_DROPDOWN_ID');
|
||||||
if (m) myself = 'reddit.com/user/' + m;
|
if (m) {
|
||||||
|
m = [...m.querySelectorAll('*')].filter(x => x.childNodes.length == 1 && x.firstChild.nodeType == 3).map(x => x.textContent)[0]
|
||||||
|
if (m) myself = 'reddit.com/user/' + m;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (hostname == 'facebook.com') {
|
||||||
if (hostname == 'facebook.com') {
|
var m = document.querySelector("[id^='profile_pic_header_']")
|
||||||
var m = document.querySelector("[id^='profile_pic_header_']")
|
if (m) myself = 'facebook.com/' + captureRegex(m.id, /header_(\d+)/);
|
||||||
if (m) myself = 'facebook.com/' + captureRegex(m.id, /header_(\d+)/);
|
|
||||||
}
|
|
||||||
if (hostname == 'twitter.com') {
|
|
||||||
myself = document.querySelector('.DashUserDropdown-userInfo a');
|
|
||||||
|
|
||||||
disableTwitterCustomCss();
|
|
||||||
|
|
||||||
var style = document.createElement('style');
|
|
||||||
style.textContent = `
|
|
||||||
|
|
||||||
.pretty-link b, .pretty-link s {
|
|
||||||
color: inherit !important;
|
|
||||||
}
|
}
|
||||||
|
if(hostname == 'medium.com') {
|
||||||
a.show-thread-link, a.ThreadedConversation-moreRepliesLink {
|
|
||||||
color: inherit !important;
|
|
||||||
|
var style = document.createElement('style');
|
||||||
|
style.textContent = `
|
||||||
|
|
||||||
|
a.show-thread-link, a.ThreadedConversation-moreRepliesLink {
|
||||||
|
color: inherit !important;
|
||||||
|
}
|
||||||
|
.fullname,
|
||||||
|
.stream-item a:hover .fullname,
|
||||||
|
.stream-item a:active .fullname
|
||||||
|
{color:inherit;}
|
||||||
|
|
||||||
|
`;
|
||||||
|
document.head.appendChild(style);
|
||||||
|
|
||||||
}
|
}
|
||||||
.fullname,
|
if (hostname == 'twitter.com') {
|
||||||
.stream-item a:hover .fullname,
|
myself = document.querySelector('.DashUserDropdown-userInfo a');
|
||||||
.stream-item a:active .fullname
|
|
||||||
{color:inherit;}
|
|
||||||
|
|
||||||
`;
|
|
||||||
document.head.appendChild(style);
|
|
||||||
|
|
||||||
}else if(hostname == 'reddit.com'){
|
var style = document.createElement('style');
|
||||||
var style = document.createElement('style');
|
style.textContent = `
|
||||||
style.textContent = `
|
|
||||||
.author { color: #369 !important;}
|
.pretty-link b, .pretty-link s {
|
||||||
`;
|
color: inherit !important;
|
||||||
document.head.appendChild(style);
|
}
|
||||||
|
|
||||||
|
a.show-thread-link, a.ThreadedConversation-moreRepliesLink {
|
||||||
|
color: inherit !important;
|
||||||
|
}
|
||||||
|
.fullname,
|
||||||
|
.stream-item a:hover .fullname,
|
||||||
|
.stream-item a:active .fullname
|
||||||
|
{color:inherit;}
|
||||||
|
|
||||||
|
`;
|
||||||
|
document.head.appendChild(style);
|
||||||
|
|
||||||
|
}else if(hostname == 'reddit.com'){
|
||||||
|
var style = document.createElement('style');
|
||||||
|
style.textContent = `
|
||||||
|
.author { color: #369 !important;}
|
||||||
|
`;
|
||||||
|
document.head.appendChild(style);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isHostedOn(hostname, 'youtube.com')) {
|
function maybeDisableCustomCss(){
|
||||||
setInterval(updateYouTubeChannelHeader, 300);
|
var shouldDisable = null;
|
||||||
}
|
if(hostname == 'twitter.com') shouldDisable = x => x.ownerNode && x.ownerNode.id && x.ownerNode.id.startsWith('user-style');
|
||||||
|
else if(hostname == 'medium.com') shouldDisable = x => x.ownerNode && x.ownerNode.className && x.ownerNode.className == 'js-collectionStyle';
|
||||||
|
else if(hostname == 'disqus.com') shouldDisable = x => x.ownerNode && x.ownerNode.id && x.ownerNode.id.startsWith('css_');
|
||||||
|
|
||||||
if (myself && (myself.href || myself.startsWith('http:') || myself.startsWith('https:')))
|
if(shouldDisable)
|
||||||
myself = getIdentifier(myself);
|
[...document.styleSheets].filter(shouldDisable).forEach(x => x.disabled = true);
|
||||||
//console.log('Myself: ' + myself)
|
|
||||||
|
|
||||||
function disableTwitterCustomCss(){
|
|
||||||
[...document.styleSheets].filter(x => x.ownerNode && x.ownerNode.id && x.ownerNode.id.startsWith('user-style')).forEach(x => x.disabled = true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
fixupSiteStyles();
|
||||||
|
|
||||||
|
if (isHostedOn(hostname, 'youtube.com')) {
|
||||||
|
setInterval(updateYouTubeChannelHeader, 300);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myself && (myself.href || myself.startsWith('http:') || myself.startsWith('https:')))
|
||||||
|
myself = getIdentifier(myself);
|
||||||
|
//console.log('Myself: ' + myself)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
maybeDisableCustomCss();
|
||||||
updateAllLabels();
|
updateAllLabels();
|
||||||
|
|
||||||
var observer = new MutationObserver(mutationsList => {
|
var observer = new MutationObserver(mutationsList => {
|
||||||
if (hostname == 'twitter.com')
|
maybeDisableCustomCss();
|
||||||
disableTwitterCustomCss();
|
|
||||||
for (var mutation of mutationsList) {
|
for (var mutation of mutationsList) {
|
||||||
if (mutation.type == 'childList') {
|
if (mutation.type == 'childList') {
|
||||||
for (var node of mutation.addedNodes) {
|
for (var node of mutation.addedNodes) {
|
||||||
@ -200,8 +230,6 @@ function initLink(a){
|
|||||||
applyLabel(a, identifier);
|
applyLabel(a, identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
var currentlySelectedEntity = null;
|
|
||||||
|
|
||||||
function isHostedOn(/** @type {string}*/fullHost, /** @type {string}*/baseHost) {
|
function isHostedOn(/** @type {string}*/fullHost, /** @type {string}*/baseHost) {
|
||||||
if (baseHost.length > fullHost.length) return false;
|
if (baseHost.length > fullHost.length) return false;
|
||||||
if (baseHost.length == fullHost.length) return baseHost == fullHost;
|
if (baseHost.length == fullHost.length) return baseHost == fullHost;
|
||||||
@ -352,11 +380,17 @@ function getIdentifierInternal(urlstr) {
|
|||||||
return 'reddit.com' + takeFirstPathComponents(url.pathname.replace('/u/', '/user/'), 2).toLowerCase();
|
return 'reddit.com' + takeFirstPathComponents(url.pathname.replace('/u/', '/user/'), 2).toLowerCase();
|
||||||
}
|
}
|
||||||
if (isHostedOn(host, 'twitter.com')) {
|
if (isHostedOn(host, 'twitter.com')) {
|
||||||
return 'twitter.com' + takeFirstPathComponents(url.pathname, 1).toLowerCase()
|
return 'twitter.com' + takeFirstPathComponents(url.pathname, 1).toLowerCase();
|
||||||
}
|
}
|
||||||
if (isHostedOn(host, 'youtube.com')) {
|
if (isHostedOn(host, 'youtube.com')) {
|
||||||
return 'youtube.com' + takeFirstPathComponents(url.pathname, 2);
|
return 'youtube.com' + takeFirstPathComponents(url.pathname, 2);
|
||||||
}
|
}
|
||||||
|
if (isHostedOn(host, 'disqus.com') && url.pathname.startsWith('/by/')) {
|
||||||
|
return 'disqus.com' + takeFirstPathComponents(url.pathname, 2);
|
||||||
|
}
|
||||||
|
if (isHostedOn(host, 'medium.com')) {
|
||||||
|
return 'medium.com' + takeFirstPathComponents(url.pathname, 1).toLowerCase();
|
||||||
|
}
|
||||||
if (host.indexOf('.blogspot.') != -1) {
|
if (host.indexOf('.blogspot.') != -1) {
|
||||||
var m = captureRegex(host, /([a-zA-Z0-9\-]*)\.blogspot/);
|
var m = captureRegex(host, /([a-zA-Z0-9\-]*)\.blogspot/);
|
||||||
if(m) return m.toLowerCase() + '.blogspot.com';
|
if(m) return m.toLowerCase() + '.blogspot.com';
|
||||||
@ -393,6 +427,10 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||||||
if (hostname == 'facebook.com' && node.dataset && node.dataset.ftr) return node;
|
if (hostname == 'facebook.com' && node.dataset && node.dataset.ftr) return node;
|
||||||
if (hostname == 'reddit.com' && (classList.contains('scrollerItem') || classList.contains('thing') || classList.contains('Comment'))) return node;
|
if (hostname == 'reddit.com' && (classList.contains('scrollerItem') || classList.contains('thing') || classList.contains('Comment'))) return node;
|
||||||
if (hostname == 'twitter.com' && (classList.contains('stream-item'))) return node;
|
if (hostname == 'twitter.com' && (classList.contains('stream-item'))) return node;
|
||||||
|
if (hostname == 'disqus.com' && (classList.contains('post-content'))) return node;
|
||||||
|
if (hostname == 'medium.com' && (classList.contains('streamItemConversationItem'))) return node;
|
||||||
|
if (hostname == 'youtube.com' && node.tagName == 'YTD-COMMENT-RENDERER') return node;
|
||||||
|
|
||||||
node = node.parentElement;
|
node = node.parentElement;
|
||||||
}
|
}
|
||||||
//console.log('Reached the top without a satisfying element')
|
//console.log('Reached the top without a satisfying element')
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Shinigami Eyes",
|
"name": "Shinigami Eyes",
|
||||||
"author": "Shinigami Eyes",
|
"author": "Shinigami Eyes",
|
||||||
"version": "1.0.2",
|
"version": "1.0.4",
|
||||||
"homepage_url": "https://github.com/shinigami-eyes/shinigami-eyes",
|
"homepage_url": "https://github.com/shinigami-eyes/shinigami-eyes",
|
||||||
"description": "Highlights transphobic/anti-LGBT and trans-friendly subreddits/users/facebook pages/groups with different colors.",
|
"description": "Highlights transphobic/anti-LGBT and trans-friendly subreddits/users/facebook pages/groups with different colors.",
|
||||||
"icons": {
|
"icons": {
|
||||||
@ -10,11 +10,14 @@
|
|||||||
},
|
},
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
|
"all_frames": true,
|
||||||
"matches": [
|
"matches": [
|
||||||
"*://*.facebook.com/*",
|
"*://*.facebook.com/*",
|
||||||
"*://*.youtube.com/*",
|
"*://*.youtube.com/*",
|
||||||
"*://*.reddit.com/*",
|
"*://*.reddit.com/*",
|
||||||
"*://*.twitter.com/*"
|
"*://*.twitter.com/*",
|
||||||
|
"*://medium.com/*",
|
||||||
|
"*://disqus.com/*"
|
||||||
],
|
],
|
||||||
"js": [
|
"js": [
|
||||||
"content.js"
|
"content.js"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user