Support for Tumblr
This commit is contained in:
parent
0d7064efa4
commit
96023a44e2
@ -81,7 +81,8 @@ function createContextMenu(text, id) {
|
|||||||
"*://*.reddit.com/*",
|
"*://*.reddit.com/*",
|
||||||
"*://*.twitter.com/*",
|
"*://*.twitter.com/*",
|
||||||
"*://medium.com/*",
|
"*://medium.com/*",
|
||||||
"*://disqus.com/*"
|
"*://disqus.com/*",
|
||||||
|
"*://*.tumblr.com/*"
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,14 @@ function fixupSiteStyles(){
|
|||||||
document.head.appendChild(style);
|
document.head.appendChild(style);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if(isHostedOn(hostname, 'tumblr.com')) {
|
||||||
|
var style = document.createElement('style');
|
||||||
|
style.textContent = `
|
||||||
|
.assigned-label-transphobic { outline: 2px solid #991515 !important; }
|
||||||
|
/*.assigned-label-t-friendly { outline: 2px #77B91E !important; }*/
|
||||||
|
`;
|
||||||
|
document.head.appendChild(style);
|
||||||
|
}
|
||||||
if (hostname == 'twitter.com') {
|
if (hostname == 'twitter.com') {
|
||||||
myself = document.querySelector('.DashUserDropdown-userInfo a');
|
myself = document.querySelector('.DashUserDropdown-userInfo a');
|
||||||
|
|
||||||
@ -250,6 +258,9 @@ function takeFirstPathComponents(/** @type {string}*/path, /** @type {number}*/n
|
|||||||
if (m.length && !m[m.length - 1]) m.length--;
|
if (m.length && !m[m.length - 1]) m.length--;
|
||||||
return '/' + m.join('/');
|
return '/' + m.join('/');
|
||||||
}
|
}
|
||||||
|
function takeNthPathComponent(/** @type {string}*/path, /** @type {number}*/nth) {
|
||||||
|
return path.split('/')[nth + 1] || null;
|
||||||
|
}
|
||||||
|
|
||||||
function captureRegex(str, regex){
|
function captureRegex(str, regex){
|
||||||
if(!str) return null;
|
if(!str) return null;
|
||||||
@ -285,7 +296,7 @@ function getIdentifier(urlstr) {
|
|||||||
try{
|
try{
|
||||||
return getIdentifierInternal(urlstr);
|
return getIdentifierInternal(urlstr);
|
||||||
}catch(e){
|
}catch(e){
|
||||||
console.warning("Unable to get identifier for " + urlstr);
|
console.warn("Unable to get identifier for " + urlstr);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,9 +371,18 @@ function getIdentifierInternal(urlstr) {
|
|||||||
if (isHostedOn(host, 'web.archive.org')) {
|
if (isHostedOn(host, 'web.archive.org')) {
|
||||||
var match = captureRegex(url.href, /\/web\/\w+\/(.*)/);
|
var match = captureRegex(url.href, /\/web\/\w+\/(.*)/);
|
||||||
if (!match) return null;
|
if (!match) return null;
|
||||||
url = new URL('http://' + match);
|
return getIdentifierInternal('http://' + match);
|
||||||
host = url.hostname;
|
|
||||||
}
|
}
|
||||||
|
if(url.search && url.search.includes('http')){
|
||||||
|
for(var q of url.searchParams){
|
||||||
|
if(q[1].startsWith('http')) return getIdentifierInternal(q[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
if(host == 't.umblr.com'){
|
||||||
|
return getIdentifierInternal(url.searchParams.get('z'));
|
||||||
|
}
|
||||||
|
*/
|
||||||
if (host.startsWith('www.')) host = host.substring(4);
|
if (host.startsWith('www.')) host = host.substring(4);
|
||||||
|
|
||||||
if (isHostedOn(host, 'facebook.com')) {
|
if (isHostedOn(host, 'facebook.com')) {
|
||||||
@ -385,6 +405,16 @@ function getIdentifierInternal(urlstr) {
|
|||||||
if (isHostedOn(host, 'medium.com')) {
|
if (isHostedOn(host, 'medium.com')) {
|
||||||
return 'medium.com' + takeFirstPathComponents(url.pathname, 1).toLowerCase();
|
return 'medium.com' + takeFirstPathComponents(url.pathname, 1).toLowerCase();
|
||||||
}
|
}
|
||||||
|
if (isHostedOn(host, 'tumblr.com')) {
|
||||||
|
if(url.pathname.startsWith('/register/follow/')) {
|
||||||
|
var name = takeNthPathComponent(url.pathname, 2);
|
||||||
|
return name ? name + '.tumblr.com' : null;
|
||||||
|
}
|
||||||
|
if(host != 'www.tumblr.com' && host != 'assets.tumblr.com' && host.indexOf('.media.') == -1) {
|
||||||
|
if (!url.pathname.startsWith('/tagged/')) return url.host.toLowerCase();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
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';
|
||||||
@ -424,6 +454,7 @@ browser.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|||||||
if (hostname == 'disqus.com' && (classList.contains('post-content'))) return node;
|
if (hostname == 'disqus.com' && (classList.contains('post-content'))) return node;
|
||||||
if (hostname == 'medium.com' && (classList.contains('streamItemConversationItem'))) return node;
|
if (hostname == 'medium.com' && (classList.contains('streamItemConversationItem'))) return node;
|
||||||
if (hostname == 'youtube.com' && node.tagName == 'YTD-COMMENT-RENDERER') return node;
|
if (hostname == 'youtube.com' && node.tagName == 'YTD-COMMENT-RENDERER') return node;
|
||||||
|
if (hostname.endsWith('tumblr.com') && classList.contains('post')) return node;
|
||||||
|
|
||||||
node = node.parentElement;
|
node = node.parentElement;
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,8 @@
|
|||||||
"*://*.reddit.com/*",
|
"*://*.reddit.com/*",
|
||||||
"*://*.twitter.com/*",
|
"*://*.twitter.com/*",
|
||||||
"*://medium.com/*",
|
"*://medium.com/*",
|
||||||
"*://disqus.com/*"
|
"*://disqus.com/*",
|
||||||
|
"*://*.tumblr.com/*",
|
||||||
],
|
],
|
||||||
"js": [
|
"js": [
|
||||||
"content.js"
|
"content.js"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user