sp00n82
noob
Vielleicht kann das ja jemand gebrauchen. Ich hab vor einiger Zeit mal ein UserScript (GreaseMonkey, ViolentMonkey) für Firefox gebastelt, das im Benachrichtigungs-Popup einen Link einfügt, mit dem man mit nur einem Klick jede neue Benachrichtigung in einem eigenen neuen Tab öffnen kann. Das spart dann doch je nach Anzahl der Benachrichtigungen eine ganze Menge Klicks.
Ein paar Einschränkungen gibt es allerdings:
Der Code:
So sieht das dann aus, oben rechts ist der neue Button zum Öffnen aller neuen Benachrichtigungen (Bild von @HTWolfi):
Ein paar Einschränkungen gibt es allerdings:
- ich habe es nur mit Firefox und ViolentMonkey getestet
- im Firefox funktioniert das nur, wenn man in den Einstellungen folgendes ändert:
Firefox Options -> Privacy & Security -> Permissions -> Block pop-up windows -> Exceptions -> Add "https://www.mtb-news.de" to the Allowed Websites list
Ansonsten wird dem Script nicht erlaubt, neue Tabs zu öffnen, und es passiert gar nix - wenn es mehr Benachrichtigungen gibt, als in dem Popup angezeigt werden können, dann werden diese nicht geöffnet
Der Code:
Javascript:
// ==UserScript==
// @name mtb-news.de - Add Open New Notifications Link
// @namespace net.sp00n
// @match https://www.mtb-news.de/forum/*
// @grant none
// @version 1.2
// @author sp00n
// @description Firefox Options -> Privacy & Security -> Permissions -> Block pop-up windows -> Exceptions -> Add "https://www.mtb-news.de" to the Allowed Websites list
// ==/UserScript==
// Adds an "open new" link to the header of the notification popup
(function() {
console.log("Init mtb-news notification observer");
var $ = jQuery;
var button, buttonString, observeElement, observer, config, li, addOpenAllLink, domain;
buttonString = "Neue öffnen";
domain = "https://www.mtb-news.de";
// Add the open all link element
addOpenAllLink = function(ele) {
var header = ele.find(".menu-header");
// The open new link already exists
if ( header.find(".open-all-notifications").length > 0 ) {
console.log("Link already exits, aborting!");
return false;
}
// Create the link element
button = $("<button />")
.addClass("open-all-notifications button--primary button button--icon button--icon--notificationsOn")
.css({
"font-size" : "0.7em"
, "position" : "relative"
, "left" : "1.5em"
})
;
button.append(
$("<span />")
.addClass("button-text")
.text(buttonString)
);
// And the click observer
button.on("mousedown", function(event) {
// Handle only left and middle mouse clicks
if ( event.which > 2 ) {
return;
}
event.preventDefault();
var list = ele.find(".listPlain")
, lis = list.find("li.menu-row.is-unread")
, as = lis.find("a.fauxBlockLink-blockLink")
, links = as.map(function() {
return $(this).attr("href");
})
, counter = 1
;
// Open each link in a new window (tab)
links.each(function(key, link) {
window.open(domain + link, "_newtab_" + counter);
counter++;
});
});
header.append(button);
};
// Observe the notification popup element
observeElement = $("div.menu[data-href='/forum/account/alerts-popup']").get(0);
// Set up a Mutation Observer
config = {
attributes : true
, attributeOldValue : true
, attributeFilter : ["class"]
};
// Observe it for class changes (which happens when it gets openend)
observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if ( mutation.attributeName == "class" ) {
var ele = $(mutation.target);
// The popup has finished opening, now we can add the open all link
if ( ele.hasClass("is-active is-complete") && !ele.hasClass("is-transitioning") ) {
addOpenAllLink(ele);
}
}
});
});
observer.observe(observeElement, config);
})();
So sieht das dann aus, oben rechts ist der neue Button zum Öffnen aller neuen Benachrichtigungen (Bild von @HTWolfi):
Zuletzt bearbeitet: