Commit f24458f3 authored by Ronane's avatar Ronane
Browse files

don't wizz on non mastodon websites, better filtered wizz events

parent d7ef1704
......@@ -2,9 +2,9 @@
"description": "Do you miss WIZZ ?",
"manifest_version": 2,
"name": "Wizztodon",
"version": "1.3",
"homepage_url": "https://framagit.org/troll/wizztodon"
"author": "@ronane@mamot.fr & @Troll@maly.io"
"version": "1.4.1",
"homepage_url": "https://framagit.org/troll/wizztodon",
"author": "@ronane@mamot.fr & @Troll@maly.io",
"permissions": [
"<all_urls>"
],
......
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
if (document.body.children[0].id === "mastodon") {
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
var expr = /tags\/wizz/i;
var config = {
attributes: false,
childList: true,
subtree: false
};
var expr = /tags\/wizz/i;
var config = {
attributes: true,
childList: true,
subtree: true
};
var callback = function (mutations, observer) {
mutations.forEach(function (mutation) {
if (mutation.type === 'childList') {
var firstChild = mutation.target.firstChild;
if (firstChild.innerHTML.match(expr)) {
console.log("wiZZ");
firstChild.className = "wizz";
var nudge = browser.extension.getURL("nudge.mp3");
console.log(nudge);
new Audio(nudge).play();
var callback = function (mutations, observer) {
mutations.forEach(function (mutation) {
if (mutation.type === 'childList' && mutation.target.className === "item-list") {
//console.log(mutation.target.parentNode.parentNode.getAttributeNode("aria-label"));
var article = mutation.target.firstChild;
if (article.innerHTML.match(expr) && article.firstChild.className !== "wizz") {
//console.log("wiZZ");
//console.log(article);
article.firstChild.className = "wizz";
var nudge = browser.extension.getURL("nudge.mp3");
new Audio(nudge).play();
}
}
}
});
};
});
};
var observer = new MutationObserver(callback);
var observer = new MutationObserver(callback);
sleep(3000).then(() => {
var columns = document.querySelectorAll("div.column div.item-list");
sleep(3000).then(() => {
var columns = document.querySelectorAll("div.column div.item-list");
columns.forEach(function (element) {
observer.observe(element, config);
columns.forEach(function (element) {
observer.observe(element, config);
});
});
});
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment