// ==UserScript== // @name 在网页上记笔记 // @namespace http://tampermonkey.net/ // @version 2024-02-16 // @description 浅浅记一下笔记。 // @author EnrynHsu // @match https://cn.bing.com/* // @match https://*/* // @icon https://www.google.com/s2/favicons?sz=64&domain=bing.com // @grant none // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/487940/%E5%9C%A8%E7%BD%91%E9%A1%B5%E4%B8%8A%E8%AE%B0%E7%AC%94%E8%AE%B0.user.js // @updateURL https://update.greasyfork.icu/scripts/487940/%E5%9C%A8%E7%BD%91%E9%A1%B5%E4%B8%8A%E8%AE%B0%E7%AC%94%E8%AE%B0.meta.js // ==/UserScript== (function() { 'use strict'; // Your code here... const editor_pad = document.createElement('div') document.body.appendChild(editor_pad) editor_pad.innerHTML = "" document.getElementById('hsu_button_edit').addEventListener('click',() => { editor_pad.innerHTML = "\n" + " " editor_pad.style.position = "fixed" editor_pad.style.top = "300px" editor_pad.style.right = "300px" editor_pad.style.width = "300px" editor_pad.style.height = "300px" editor_pad.style.zIndex = "99999999999999" editor_pad.id = "hsu_editor_pad" dragElement(editor_pad) }) // editor_pad.innerHTML = "\n" + // " " editor_pad.style.position = "fixed" editor_pad.style.bottom = "0px" editor_pad.style.right = "10px" editor_pad.style.width = "300px" editor_pad.style.height = "300px" editor_pad.style.zIndex = "9999999999999999" editor_pad.id = "hsu_editor_pad" function dragElement(element) { let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0; if (document.getElementById(element.id + "header")) { // 如果存在,标题是您从中移动 DIV 的位置: document.getElementById(element.id + "header").onmousedown = dragMouseDown; } else { // 否则,从 DIV 内的任何位置移动 DIV: element.onmousedown = dragMouseDown; } function dragMouseDown(e) { e = e || window.event; e.preventDefault(); // 在启动时获取鼠标光标位置: pos3 = e.clientX; pos4 = e.clientY; document.onmouseup = closeDragElement; // 每当光标移动时调用一个函数: document.onmousemove = elementDrag; } function elementDrag(e) { e = e || window.event; e.preventDefault(); // 计算新的光标位置: pos1 = pos3 - e.clientX; pos2 = pos4 - e.clientY; pos3 = e.clientX; pos4 = e.clientY; // 设置元素的新位置: element.style.top = (element.offsetTop - pos2) + "px"; element.style.left = (element.offsetLeft - pos1) + "px"; } function closeDragElement() { // 释放鼠标按钮时停止移动: document.onmouseup = null; document.onmousemove = null; } } })();