Im Newsticker pro Tag die Option zum laden der Anzahl der Kommentare
当前为
// ==UserScript==
// @name heiseNewsTickerKommentare
// @version 0.1.1
// @author _leBluem_
// @description Im Newsticker pro Tag die Option zum laden der Anzahl der Kommentare
// @info its fun to see ;)
// @grant none
// @namespace https://greasyfork.org/de/users/83368-lebluem
// @match http://www.heise.de/newsticker/*
// @match https://www.heise.de/newsticker/*
// ==/UserScript==
(function() {
// add "Kommentare laden" link to date that calls GetComments
$("h4.published.archiv_woche_published").each(function(){
var s = '<font size="1"> <a href="#" onclick="GetComments(this);return false;">Kommentare laden</a></font>';
$(this).append(s);
});
// find all comments for this day
window.GetComments = function GetComments(e){
// <archiv_woche_published><font><a>
var ulist=$(e).parent().parent().next().children();
// clear all previous loaded comments
$('span[id*="plugin-page-"]').each(function(){
$(this).remove();
});
// make a span-tag to hold the comments-tag
var urls = [];
var j = 0;
$(ulist).each(function(){
if ( $(this).find('a').attr('href') ) {
urls.push($(this).find('a').attr('href'));
// #plugin-page-0 .. #plugin-page-1 .. #plugin-page-2 ..
$(this).append('<font size="1"><span id="plugin-page-' + j++ + '"></span></font>');
}
});
// make the span-tag actually load the comments-tag
if ( urls.length > 0 ) {
for (var i = 0; i<= urls.length; i++) {
// var re = new RegExp(/Kommentare lesen(.*)\(([^)]+)\)/); // does not compute anywhere
$("#plugin-page-"+i).load(urls[i] + " div.link_forum_beitrag.news p a");
}
}
};
})();