InfoSelection

Select the info.

  1. // ==UserScript==
  2. // @name InfoSelection
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Select the info.
  6. // @author zxk2099
  7. // @match https://solar.ofweek.com/*
  8. // @grant GM_setClipboard
  9. // @run-at document-end
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=gf.qytechs.cn
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // Your code here...
  17. // 创建悬浮按钮
  18. var button = document.createElement('button');
  19. button.innerHTML = '复制信息';
  20. button.style.position = 'fixed';
  21. button.style.right = '20px';
  22. button.style.top = '50%';
  23. button.style.transform = 'translateY(-50%)';
  24. button.style.padding = '10px 20px';
  25. button.style.fontSize = '16px';
  26. button.style.backgroundColor = '#4CAF50';
  27. button.style.color = 'white';
  28. button.style.border = 'none';
  29. button.style.borderRadius = '5px';
  30. button.style.cursor = 'pointer';
  31. button.style.zIndex = '9999';
  32.  
  33. // 将按钮添加到页面
  34. document.body.appendChild(button);
  35.  
  36. // 点击按钮时获取信息并复制到剪贴板
  37. button.addEventListener('click', function() {
  38. // 获取标题、时间和网页地址
  39. var title = document.querySelector('p.title');
  40. var time = document.querySelector('div.time.fl');
  41. var url = window.location.href;
  42.  
  43. // 如果找到了标题和时间元素,格式化文本
  44. if (title && time) {
  45. var titleText = title.innerText.trim();
  46. var timeText = time.innerText.trim().toLocaleString().split(" ")[0];
  47.  
  48. // 格式化复制的内容
  49. var textToCopy = `${timeText}\t\t\t${titleText}\t${url}`;
  50.  
  51. // 使用 GM_setClipboard 将内容复制到剪贴板
  52. GM_setClipboard(textToCopy);
  53. alert('信息已复制到剪贴板!');
  54. } else {
  55. alert('未能找到标题或时间元素!');
  56. }
  57. });
  58.  
  59. })();

QingJ © 2025

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