Greasy Fork is available in English.

雪球个股调研备注

为雪球的每个个股页面增加备注,保存到浏览器本地

  1. // ==UserScript==
  2. // @name 雪球个股调研备注
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.2
  5. // @description 为雪球的每个个股页面增加备注,保存到浏览器本地
  6. // @author Xirtam
  7. // @match https://xueqiu.com/S/*
  8. // @icon https://www.google.com/s2/favicons?sz=64&domain=xueqiu.com
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. // 获取当前页面的 URL
  16. const currentUrl = location.origin + location.pathname;
  17. // 从本地存储中获取与当前 URL 相关联的备注
  18. const note = localStorage.getItem(`note:${currentUrl}`);
  19.  
  20. // 将按钮添加到页面上
  21. const div = document.createElement('div');
  22. div.style.display = 'block';
  23. div.style.position = 'fixed';
  24. div.style.top = '50%';
  25. div.style.left = '10px'; // 将 left 设为 auto
  26. div.style.right = 'auto'; // 将 right 设为 10px
  27. div.style.width = '280px'; // 宽度
  28. div.style.transform = 'translate(0%, -50%)';
  29. div.style.zIndex = 10000;
  30.  
  31. // 创建一个对话框元素
  32. const dialog = document.createElement('dialog');
  33.  
  34.  
  35. // 创建一个文本输入框元素
  36. const input = document.createElement('textarea');
  37. input.rows = 5;
  38. input.style.width = '250px';// 宽度
  39. input.style.height = '380px';
  40. input.value = note;
  41. div.appendChild(input);
  42.  
  43. // 创建一个“保存”按钮
  44. const saveButton = document.createElement('button');
  45. saveButton.textContent = '保存';
  46. saveButton.onclick = () => {
  47. const newNote = input.value;
  48. localStorage.setItem(`note:${currentUrl}`, newNote);
  49. alert('保存成功!');
  50. div.close();
  51. };
  52. div.appendChild(saveButton);
  53.  
  54. document.body.appendChild(div);
  55.  
  56. })();