Commit d7085b81 authored by Ronane's avatar Ronane
Browse files

Compatibilité framapiaf

parent f24458f3
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 mastodonSite = false;
//console.log("Début attente avant check mastodon");
sleep(3000).then(() => {
var bodyChildren = document.body.childNodes;
bodyChildren.forEach(function (elem) {
if (elem.id === "mastodon") {
mastodonSite = true;
}
});
var expr = /tags\/wizz/i;
var config = {
attributes: false,
childList: true,
subtree: false
};
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();
//console.log("C'est du masto ? " + mastodonSite);
if (mastodonSite) {
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver;
var expr = /tags\/wizz/i;
var config = {
attributes: false,
childList: true,
subtree: false
};
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