Appinn comment

Display the comments from the Appinn forum on the bottom of the corresponding page on the main site.

  1. // ==UserScript==
  2. // @name Appinn comment
  3. // @name:zh-CN 小众软件评论显示
  4. // @namespace hoothin
  5. // @version 2024-06-08
  6. // @description Display the comments from the Appinn forum on the bottom of the corresponding page on the main site.
  7. // @description:zh-CN 将小众软件论坛的评论内容显示在主站对应页面下部
  8. // @author hoothin
  9. // @match https://www.appinn.com/*
  10. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  11. // @grant GM_xmlhttpRequest
  12. // @connect meta.appinn.net
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. const commentLink = document.querySelector('a.wpdc-join-discussion-link');
  18. if (!commentLink) return;
  19. GM_xmlhttpRequest({
  20. url: commentLink.href,
  21. method: 'GET',
  22. onload: function(res) {
  23. try {
  24. let doc = document.implementation.createHTMLDocument('');
  25. doc.documentElement.innerHTML = res.response;
  26. let dataPreloaded = doc.getElementById('data-preloaded');
  27. if (!dataPreloaded) return;
  28. dataPreloaded = JSON.parse(JSON.parse(dataPreloaded.dataset.preloaded)["topic_" + commentLink.href.match(/\d+/)[0]]).post_stream.posts;
  29. let posts = document.createElement("ul");
  30. posts.style.maxHeight = '90vh';
  31. posts.style.overflow = 'auto';
  32. posts.style.margin = '0';
  33. let title = document.createElement("h3");
  34. title.innerText = "评论内容";
  35. document.querySelector('article').appendChild(title);
  36. document.querySelector('article').appendChild(posts);
  37. dataPreloaded.forEach(item => {
  38. posts.innerHTML += `<li style='border-top: 1px solid #313131;'><p style='font-weight: bold;'>${item.display_username || item.username}</p>${item.cooked}</li>`;
  39. });
  40. } catch (e) {
  41. }
  42. }
  43. });
  44. })();