Initial support for site homepages
This commit is contained in:
parent
825274213a
commit
ce74cda636
@ -384,6 +384,18 @@ function createContextMenu(text: string, id: ContextMenuCommand) {
|
|||||||
"*://*.google.com/*",
|
"*://*.google.com/*",
|
||||||
"*://*.bing.com/*",
|
"*://*.bing.com/*",
|
||||||
"*://duckduckgo.com/*",
|
"*://duckduckgo.com/*",
|
||||||
|
|
||||||
|
"*://*/",
|
||||||
|
"*://*/about*",
|
||||||
|
"*://*/contact*",
|
||||||
|
"*://*/faq*",
|
||||||
|
"*://*/blog",
|
||||||
|
"*://*/blog/",
|
||||||
|
"*://*/news",
|
||||||
|
"*://*/news/",
|
||||||
|
"*://*/en/",
|
||||||
|
"*://*/index.html",
|
||||||
|
"*://*/index.php",
|
||||||
]
|
]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ if (hostname.endsWith('.facebook.com')) hostname = 'facebook.com';
|
|||||||
if (hostname.endsWith('.youtube.com')) hostname = 'youtube.com';
|
if (hostname.endsWith('.youtube.com')) hostname = 'youtube.com';
|
||||||
|
|
||||||
var myself: string = null;
|
var myself: string = null;
|
||||||
|
var isSocialNetwork: boolean = null;
|
||||||
|
|
||||||
function fixupSiteStyles() {
|
function fixupSiteStyles() {
|
||||||
if (hostname == 'facebook.com') {
|
if (hostname == 'facebook.com') {
|
||||||
@ -81,6 +82,21 @@ function maybeDisableCustomCss() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
isSocialNetwork = [
|
||||||
|
'facebook.com',
|
||||||
|
'youtube.com',
|
||||||
|
'reddit.com',
|
||||||
|
'twitter.com',
|
||||||
|
'medium.com',
|
||||||
|
'disqus.com',
|
||||||
|
'rationalwiki.org',
|
||||||
|
'duckduckgo.com',
|
||||||
|
'bing.com',
|
||||||
|
].includes(hostname) ||
|
||||||
|
domainIs(hostname, 'tumblr.com') ||
|
||||||
|
domainIs(hostname, 'wikipedia.org') ||
|
||||||
|
/^google(\.co)?\.\w+$/.test(hostname);
|
||||||
|
|
||||||
fixupSiteStyles();
|
fixupSiteStyles();
|
||||||
|
|
||||||
if (domainIs(hostname, 'youtube.com')) {
|
if (domainIs(hostname, 'youtube.com')) {
|
||||||
@ -93,36 +109,38 @@ function init() {
|
|||||||
|
|
||||||
console.log('Self: ' + myself)
|
console.log('Self: ' + myself)
|
||||||
|
|
||||||
|
document.addEventListener('contextmenu', evt => {
|
||||||
|
lastRightClickedElement = <HTMLElement>evt.target;
|
||||||
|
}, true);
|
||||||
|
|
||||||
maybeDisableCustomCss();
|
maybeDisableCustomCss();
|
||||||
updateAllLabels();
|
updateAllLabels();
|
||||||
|
|
||||||
var observer = new MutationObserver(mutationsList => {
|
if (isSocialNetwork) {
|
||||||
maybeDisableCustomCss();
|
var observer = new MutationObserver(mutationsList => {
|
||||||
for (const mutation of mutationsList) {
|
maybeDisableCustomCss();
|
||||||
if (mutation.type == 'childList') {
|
for (const mutation of mutationsList) {
|
||||||
for (const node of mutation.addedNodes) {
|
if (mutation.type == 'childList') {
|
||||||
if (node instanceof HTMLAnchorElement) {
|
for (const node of mutation.addedNodes) {
|
||||||
initLink(node);
|
if (node instanceof HTMLAnchorElement) {
|
||||||
}
|
initLink(node);
|
||||||
if (node instanceof HTMLElement) {
|
}
|
||||||
for (const subnode of node.querySelectorAll('a')) {
|
if (node instanceof HTMLElement) {
|
||||||
initLink(subnode);
|
for (const subnode of node.querySelectorAll('a')) {
|
||||||
|
initLink(subnode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
solvePendingLabels();
|
||||||
solvePendingLabels();
|
});
|
||||||
});
|
|
||||||
|
|
||||||
observer.observe(document.body, {
|
observer.observe(document.body, {
|
||||||
childList: true,
|
childList: true,
|
||||||
subtree: true
|
subtree: true
|
||||||
});
|
});
|
||||||
|
}
|
||||||
document.addEventListener('contextmenu', evt => {
|
|
||||||
lastRightClickedElement = <HTMLElement>evt.target;
|
|
||||||
}, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastRightClickedElement: HTMLElement = null;
|
var lastRightClickedElement: HTMLElement = null;
|
||||||
@ -178,8 +196,10 @@ function updateYouTubeChannelHeader() {
|
|||||||
|
|
||||||
function updateAllLabels(refresh?: boolean) {
|
function updateAllLabels(refresh?: boolean) {
|
||||||
if (refresh) knownLabels = {};
|
if (refresh) knownLabels = {};
|
||||||
for (const a of document.getElementsByTagName('a')) {
|
if (isSocialNetwork) {
|
||||||
initLink(a);
|
for (const a of document.getElementsByTagName('a')) {
|
||||||
|
initLink(a);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
solvePendingLabels();
|
solvePendingLabels();
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
"*://duckduckgo.com/*",
|
"*://duckduckgo.com/*",
|
||||||
"*://*.bing.com/*",
|
"*://*.bing.com/*",
|
||||||
|
|
||||||
"*://*.google.ar/*",
|
"*://*.google.ar/*",
|
||||||
"*://*.google.at/*",
|
"*://*.google.at/*",
|
||||||
"*://*.google.be/*",
|
"*://*.google.be/*",
|
||||||
@ -44,12 +44,18 @@
|
|||||||
"*://*.google.pt/*",
|
"*://*.google.pt/*",
|
||||||
"*://*.google.se/*"
|
"*://*.google.se/*"
|
||||||
],
|
],
|
||||||
"js": [
|
|
||||||
"content.js"
|
|
||||||
],
|
|
||||||
"css": [
|
"css": [
|
||||||
"content.css"
|
"content.css"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"all_frames": true,
|
||||||
|
"matches": [
|
||||||
|
"*://*/*"
|
||||||
|
],
|
||||||
|
"js": [
|
||||||
|
"content.js"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"web_accessible_resources": [
|
"web_accessible_resources": [
|
||||||
|
Loading…
x
Reference in New Issue
Block a user