简单易用一键保存当前网页,无需复杂操作。自动化离线保存,方便又高效

永久保存重要内容

目前為 2025-01-09 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name 简单易用一键保存当前网页,无需复杂操作。自动化离线保存,方便又高效
  3. // @namespace 保存当前网页实现离线浏览
  4. // @version 1.1
  5. // @description 永久保存重要内容
  6. // @author 让雅克卢梭博客园
  7. // @match *://*/*
  8. // @license MIT
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // 获取当前页面的 URL
  16. const currentUrl = window.location.href;
  17.  
  18. // 创建一个按钮元素
  19. const button = document.createElement('button');
  20. button.textContent = '保存到 Archive.today';
  21. button.style.position = 'fixed';
  22. button.style.bottom = '20px';
  23. button.style.right = '20px';
  24. button.style.backgroundColor = '#007bff';
  25. button.style.color = '#fff';
  26. button.style.border = 'none';
  27. button.style.padding = '10px 15px';
  28. button.style.borderRadius = '5px';
  29. button.style.cursor = 'pointer';
  30. button.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.3)';
  31. button.style.zIndex = '9999';
  32.  
  33. // 按钮点击事件
  34. button.addEventListener('click', () => {
  35. // 创建一个隐藏的表单并提交到 archive.today
  36. const form = document.createElement('form');
  37. form.method = 'POST';
  38. form.action = 'https://archive.today/submit/';
  39. form.target = '_blank'; // 打开新标签
  40.  
  41. // 添加 URL 输入字段
  42. const input = document.createElement('input');
  43. input.type = 'hidden';
  44. input.name = 'url';
  45. input.value = currentUrl;
  46. form.appendChild(input);
  47.  
  48. // 将表单添加到文档并提交
  49. document.body.appendChild(form);
  50. form.submit();
  51.  
  52. // 提交后移除表单
  53. document.body.removeChild(form);
  54. });
  55.  
  56. // 添加拖动功能
  57. let isDragging = false;
  58. let offsetX, offsetY;
  59.  
  60. button.addEventListener('mousedown', (e) => {
  61. isDragging = true;
  62. offsetX = e.clientX - button.getBoundingClientRect().left;
  63. offsetY = e.clientY - button.getBoundingClientRect().top;
  64. button.style.cursor = 'grabbing'; // 更改鼠标样式
  65. });
  66.  
  67. document.addEventListener('mousemove', (e) => {
  68. if (isDragging) {
  69. const x = e.clientX - offsetX;
  70. const y = e.clientY - offsetY;
  71. button.style.left = `${x}px`;
  72. button.style.top = `${y}px`;
  73. button.style.bottom = 'auto'; // 禁止固定在底部
  74. button.style.right = 'auto'; // 禁止固定在右边
  75. }
  76. });
  77.  
  78. document.addEventListener('mouseup', () => {
  79. isDragging = false;
  80. button.style.cursor = 'pointer'; // 恢复鼠标样式
  81. });
  82.  
  83. // 将按钮添加到页面
  84. document.body.appendChild(button);
  85. })();

QingJ © 2025

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