xiaohongshu Collect

xiaohongshu collect shortcut

  1. // ==UserScript==
  2. // @name xiaohongshu Collect
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.0
  5. // @description xiaohongshu collect shortcut
  6. // @author onionycs
  7. // @match https://www.xiaohongshu.com/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=xiaohongshu.com
  9. // @require http://code.jquery.com/jquery-3.x-git.min.js
  10. // @grant none
  11. // @license mit
  12. // ==/UserScript==
  13.  
  14. (function () {
  15. "use strict";
  16. /* globals jQuery, $, waitForKeyElements */
  17.  
  18. document.addEventListener("keydown", function (event) {
  19. const pElement = document.getElementById('content-textarea');
  20. const target = event.target;
  21. // 判断当前焦点元素是否是input元素
  22. if (target.tagName !== "INPUT" && target.tagName !== "TEXTAREA" && event.target!== pElement) {
  23. if (event.key === "a" || event.key === "A") {
  24. document.getElementsByClassName('feeds-container')[0].style.display = 'none';
  25. document.getElementsByClassName('information-wrapper')[0].click();
  26. setTimeout(function() {
  27. document.getElementById('access-min-window').click();
  28. }, 500);
  29. }
  30.  
  31. if (event.key === "s" || event.key === "S") {
  32. document.getElementsByClassName("collect-wrapper")[0].click();
  33. setTimeout(function () {
  34. document.getElementsByClassName("right-area")[0].click();
  35. }, 500);
  36. }
  37. if (event.key === "t" || event.key === "T") {
  38. // 获取第一个具有 'feeds-container' 类名的元素
  39. const element = document.getElementsByClassName('feeds-container')[0];
  40. // 检查元素是否存在
  41. if (element) {
  42. // 如果元素当前的 display 属性为 'none'
  43. if (element.style.display === 'none') {
  44. // 则将其设置为 'block'
  45. element.style.display = 'block';
  46. } else {
  47. // 否则将其设置为 'none'
  48. element.style.display = 'none';
  49. }
  50. }
  51. }
  52.  
  53. if (event.key === "z" || event.key === "Z") {
  54. // 获取 .btn-wrapper 的第一个元素中的 <use> 标签
  55. var useElement = document.getElementsByClassName('btn-wrapper')[0].querySelector('use');
  56.  
  57. // 获取 <use> 标签的 xlink:href 属性值
  58. var xlinkHref = useElement.getAttribute('xlink:href');
  59.  
  60. // 判断 xlink:href 的值并执行操作
  61. if (xlinkHref === '#imgNote') {
  62. // 图文没有被选中且会包含短视频,执行点击操作
  63. document.getElementsByClassName('btn-wrapper')[0].click();
  64. }
  65. showNotification("已经为您过滤短视频内容");
  66. }
  67. }
  68. });
  69.  
  70. // 函数:在页面右上方显示提示信息
  71. function showNotification(message,topp) {
  72. // 创建通知元素
  73. const $notification = $("<div></div>")
  74. .text(message)
  75. .css({
  76. position: "fixed",
  77. top: topp,
  78. right: "20px",
  79. padding: "10px 20px",
  80. backgroundColor: "#f44336", // 红色背景
  81. color: "white",
  82. borderRadius: "5px",
  83. boxShadow: "0 2px 5px rgba(0, 0, 0, 0.3)",
  84. zIndex: 1000,
  85. fontSize: "14px",
  86. opacity: 0,
  87. });
  88.  
  89. // 将通知元素添加到页面
  90. $("body").append($notification);
  91.  
  92. // 动画显示通知
  93. $notification.animate({ opacity: 1 }, 500, function() {
  94. // 3秒后自动隐藏通知
  95. setTimeout(function() {
  96. $notification.animate({ opacity: 0 }, 500, function() {
  97. $notification.remove();
  98. });
  99. }, 3000);
  100. });
  101. }
  102. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址