Top comments in the bottom of osnova platforms' articles.

osnova, why did you do that? :(

  1. // ==UserScript==
  2. // @name Top comments in the bottom of osnova platforms' articles.
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.4
  5. // @description osnova, why did you do that? :(
  6. // @author curoviyxru
  7. // @match https://dtf.ru/*-*
  8. // @match https://tjournal.ru/*-*
  9. // @match https://vc.ru/*-*
  10. // @grant none
  11. // @license MIT
  12. // @require https://code.jquery.com/jquery-3.5.1.min.js
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. (function($){
  18. console.log("Fetching top comments...");
  19. $.get("https://api." + window.location.hostname + "/v1.9/entry/" + $(".l-entry").attr("data-content-id") + "/widgets", function (data) {
  20. //console.log(data);
  21.  
  22. var color = "blue";
  23. switch (window.location.hostname) {
  24. case "dtf.ru":
  25. color = "blue";
  26. break;
  27. case "vc.ru":
  28. color = "pink";
  29. break;
  30. case "tjournal.ru":
  31. color = "yellow";
  32. break;
  33. }
  34.  
  35. $(".comments").parent().after(
  36. "<div class=\"l-island-round lm-pv-15 lm-mt-20 l-mt-28\"><div class=\"widget_wrapper widget_wrapper--type-" + color + " l-pt-20 l-island-round\" data-gtm=\"Feed — Best Comments Widget — Clicked\">"
  37. + "<div class=\"l-island-a\">"
  38.  
  39. + "<div class=\"widget_wrapper__title l-fs-15 l-lh-18 l-iflex l-fa-center\">Лучшие комментарии</div>"
  40.  
  41. + "<div class=\"widget_wrapper__content l-pt-15 l-pb-18\">"
  42.  
  43. + "<div class=\"widget_comment widget_wrapper__item\">"
  44. + "<div class=\"widget_comment__head l-flex l-fa-center\">"
  45. + "<a href=\"https://" + window.location.hostname + "/u/" + data.result[1].items[0].author.id + "-" + data.result[1].items[0].author.name.toLowerCase() + "\" class=\"widget_comment__author l-flex l-fa-center t-link\">"
  46. + "<img class=\"andropov_image widget_comment__author__avatar andropov_image--bordered\" air-module=\"module.andropov\" data-andropov-type=\"image\" data-image-src=\"" + data.result[1].items[0].author.avatar_url + "\" data-image-name=\"\" style=\"background-color: transparent; --darkreader-inline-bgcolor:transparent;\" src=\"" + data.result[1].items[0].author.avatar_url + "-/scale_crop/64x64/-/format/webp/\" data-darkreader-inline-bgcolor=\"\">"
  47. + "<div class=\"widget_comment__author__name l-fs-15 l-fw-500 l-ml-10\">" + data.result[1].items[0].author.name + "</div>"
  48. + "</a>"
  49. + "<div class=\"widget_comment__label l-fs-15 l-ml-20 lm-hidden\">" + data.result[1].title + "</div>"
  50. + "<air module=\"module.comments_admin\"></air>"
  51. + "<div class=\"etc_control l-ml-20\" air-module=\"module.etc_controls\" data-permissions=\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7ImhpZGVfdG9wX2NvbW1lbnQiOm51bGx9LCJpYXQiOjE2NDUwNDI0OTUsImV4cCI6MTY0NTEyODg5NX0.E9PkLS9P6gh8bNecrYMP6Zypx7bcM4LKh3xx6IBmktA\" data-url=\"/admin/comments/hide_top_comment_of_the_day/" + data.result[1].items[0].id + "\"><svg class=\"icon icon--ui_etc\" width=\"14\" height=\"7\" xmlns=\"http://www.w3.org/2000/svg\"><use xlink:href=\"#ui_etc\"></use></svg></div> "
  52. + "<div class=\"widget_comment__likes l-ml-auto l-fs-16\">" + data.result[1].items[0].likes.count + "</div>"
  53. + "</div>"
  54. + "<a href=\"" + data.result[1].items[0].entry.url + "?comment=" + data.result[1].items[0].id + "\" class=\"widget_comment__content l-block l-pv-15\"><div class=\"widget_comment__content__text l-fs-15 l-lh-22\">" + data.result[1].items[0].text + "</div></a>"
  55. + "<a href=\"" + data.result[1].items[0].entry.url + "\" class=\"widget_comment__entry l-inline-block l-fs-13 l-lh-20 l-fw-500 t-link\">" + data.result[1].items[0].entry.title + "</a>"
  56. + "</div>"
  57.  
  58. + "<div class=\"widget_comment widget_wrapper__item\">"
  59. + "<div class=\"widget_comment__head l-flex l-fa-center\">"
  60. + "<a href=\"https://" + window.location.hostname + "/u/" + data.result[2].items[0].author.id + "-" + data.result[2].items[0].author.name.toLowerCase() + "\" class=\"widget_comment__author l-flex l-fa-center t-link\">"
  61. + "<img class=\"andropov_image widget_comment__author__avatar andropov_image--bordered\" air-module=\"module.andropov\" data-andropov-type=\"image\" data-image-src=\"" + data.result[2].items[0].author.avatar_url + "\" data-image-name=\"\" style=\"background-color: transparent; --darkreader-inline-bgcolor:transparent;\" src=\"" + data.result[2].items[0].author.avatar_url + "-/scale_crop/64x64/-/format/webp/\" data-darkreader-inline-bgcolor=\"\">"
  62. + "<div class=\"widget_comment__author__name l-fs-15 l-fw-500 l-ml-10\">" + data.result[2].items[0].author.name + "</div>"
  63. + "</a>"
  64. + "<div class=\"widget_comment__label l-fs-15 l-ml-20 lm-hidden\">" + data.result[2].title + "</div>"
  65. + "<air module=\"module.comments_admin\"></air>"
  66. + "<div class=\"etc_control l-ml-20\" air-module=\"module.etc_controls\" data-permissions=\"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7ImhpZGVfdG9wX2NvbW1lbnQiOm51bGx9LCJpYXQiOjE2NDUwNDI0OTUsImV4cCI6MTY0NTEyODg5NX0.E9PkLS9P6gh8bNecrYMP6Zypx7bcM4LKh3xx6IBmktA\" data-url=\"/admin/comments/hide_top_comment_of_the_day/" + data.result[2].items[0].id + "\"><svg class=\"icon icon--ui_etc\" width=\"14\" height=\"7\" xmlns=\"http://www.w3.org/2000/svg\"><use xlink:href=\"#ui_etc\"></use></svg></div> "
  67. + "<div class=\"widget_comment__likes l-ml-auto l-fs-16\">" + data.result[2].items[0].likes.count + "</div>"
  68. + "</div>"
  69. + "<a href=\"" + data.result[2].items[0].entry.url + "?comment=" + data.result[2].items[0].id + "\" class=\"widget_comment__content l-block l-pv-15\"><div class=\"widget_comment__content__text l-fs-15 l-lh-22\">" + data.result[2].items[0].text + "</div></a>"
  70. + "<a href=\"" + data.result[2].items[0].entry.url + "\" class=\"widget_comment__entry l-inline-block l-fs-13 l-lh-20 l-fw-500 t-link\">" + data.result[2].items[0].entry.title + "</a>"
  71. + "</div>"
  72.  
  73. + "</div>"
  74.  
  75. + "</div>"
  76. + "</div></div>");
  77. });
  78. })(jQuery);
  79. })();