2 // @name LOR comment-answers
3 // @description Ответы на комментарии для linux.org.ru. Отображаются только те ответы, которые есть на текущей странице.
4 // @author indvd00m <gotoindvdum [at] gmail [dot] com>
5 // @license Creative Commons Attribution 3.0 Unported
7 // @namespace http://www.linux.org.ru/*
8 // @namespace https://www.linux.org.ru/*
9 // @include http://www.linux.org.ru/*
10 // @include https://www.linux.org.ru/*
13 // running js-code in a page context
14 var execute = function (body) {
15 if(typeof body === "function") { body = "(" + body + ")();"; }
16 var el = document.createElement("script");
17 el.textContent = body;
18 document.body.appendChild(el);
22 (function (window, undefined) {
24 if (typeof unsafeWindow != undefined) {
30 if (w.self != w.top) {
34 if (/https?:\/\/(www\.)?linux.org.ru/.test(w.location.href)) {
38 var url = $(location).attr("href").replace(/#.*$/, "");
40 $(".title").has("a[data-samepage='samePage']").each(function(index) {
42 var replyUrl = $("a", $(this)).prop("href");
43 var replyMsgId = replyUrl.match(/.*[\?\&]?cid=(\d+).*/)[1];
45 var nick = $("a[itemprop='creator']", $(this).next()).text();
46 var msgId = $(this).parent().prop("id").match(/comment-(\d+)/)[1];
47 var anchorName = "anchor-msg-" + msgId;
48 var anchor = $("<a name='" + anchorName + "'></a>");
49 $(this).prepend(anchor);
51 $("#comment-" + replyMsgId).each(function() {
53 var href = url + "#" + anchorName;
54 var link = $("<a href='" + href + "'>" + nick + "</a>");
56 var container = $(".msg_body", $(this));
57 var answersClass = "answers";
58 var answers = $("." + answersClass, container);
59 if (!answers.length) {
60 answers = $("<div class='" + answersClass + "'>Ответы: </div>");
61 answers.css("font-size", "smaller");
62 container.append(answers);
64 if (answers.children().length) {