// ==UserScript== // @name GoodNote - VSCode 网页笔记助手 // @namespace http://tampermonkey.net/ // @version 0.3.1 // @description 在任何网页添加VSCode编辑器功能 ctrl + shift + L // @author kasusa // @license MIT // @match *://*/* // @icon http://139.196.171.60:88/images/code/code.png // @grant GM_setValue // @grant GM_getValue // @downloadURL https://update.greasyfork.icu/scripts/526873/GoodNote%20-%20VSCode%20%E7%BD%91%E9%A1%B5%E7%AC%94%E8%AE%B0%E5%8A%A9%E6%89%8B.user.js // @updateURL https://update.greasyfork.icu/scripts/526873/GoodNote%20-%20VSCode%20%E7%BD%91%E9%A1%B5%E7%AC%94%E8%AE%B0%E5%8A%A9%E6%89%8B.meta.js // ==/UserScript== (function() { 'use strict'; // 创建模糊背景遮罩 const blurOverlay = document.createElement('div'); blurOverlay.style.position = 'fixed'; blurOverlay.style.top = '0'; blurOverlay.style.left = '0'; blurOverlay.style.width = '100%'; blurOverlay.style.height = '100%'; blurOverlay.style.backgroundColor = 'rgba(0, 0, 0, 0.4)'; blurOverlay.style.backdropFilter = 'blur(5px)'; blurOverlay.style.WebkitBackdropFilter = 'blur(5px)'; // Safari 支持 blurOverlay.style.zIndex = '9998'; // 确保在编辑器下面 blurOverlay.style.display = 'none'; blurOverlay.style.transition = 'opacity 0.2s ease'; blurOverlay.style.opacity = '0'; document.body.appendChild(blurOverlay); const editorContainer = document.createElement('div'); editorContainer.style.position = 'fixed'; editorContainer.style.bottom = '-100%'; // 初始位置在屏幕下方 editorContainer.style.left = '15%'; editorContainer.style.width = '70%'; editorContainer.style.height = '80%'; editorContainer.style.zIndex = '9999'; editorContainer.style.backgroundColor = '#1e1e1e'; editorContainer.style.border = '2.5px solid rgb(0, 237, 229)'; editorContainer.style.borderRadius = '10px'; editorContainer.style.boxShadow = '0 4px 8px rgba(0, 0, 0, 0.43)'; editorContainer.style.display = 'none'; editorContainer.style.padding = '15px'; editorContainer.style.transition = 'bottom 0.2s ease'; // 添加过渡效果 editorContainer.style.textAlign = 'left'; // 强制文本左对齐 editorContainer.style.margin = '0'; // 清除可能的外边距 // 创建语言选择下拉菜单 const languageSelect = document.createElement('select'); languageSelect.style.position = 'absolute'; languageSelect.style.top = '10px'; languageSelect.style.right = '10px'; languageSelect.style.padding = '5px'; languageSelect.style.backgroundColor = '#2d2d2d'; languageSelect.style.color = '#fff'; languageSelect.style.border = '1px solid #454545'; languageSelect.style.borderRadius = '4px'; languageSelect.style.zIndex = '10001'; // 添加常用语言选项 const languages = [ { id: 'javascript', name: 'JavaScript' }, { id: 'typescript', name: 'TypeScript' }, { id: 'html', name: 'HTML' }, { id: 'css', name: 'CSS' }, { id: 'python', name: 'Python' }, { id: 'java', name: 'Java' }, { id: 'cpp', name: 'C++' }, { id: 'csharp', name: 'C#' }, { id: 'php', name: 'PHP' }, { id: 'sql', name: 'SQL' }, { id: 'markdown', name: 'Markdown' }, { id: 'json', name: 'JSON' }, { id: 'plaintext', name: '纯文本' } ]; languages.forEach(lang => { const option = document.createElement('option'); option.value = lang.id; option.textContent = lang.name; languageSelect.appendChild(option); }); editorContainer.appendChild(languageSelect); document.body.appendChild(editorContainer); // 添加代码图标 const codeIcon = document.createElement('div'); codeIcon.style.position = 'fixed'; codeIcon.style.bottom = '10px'; codeIcon.style.right = '10px'; codeIcon.style.width = '50px'; codeIcon.style.height = '50px'; codeIcon.style.backgroundImage = 'url(http://139.196.171.60:88/images/code/code.png)'; codeIcon.style.backgroundSize = 'cover'; codeIcon.style.cursor = 'pointer'; codeIcon.style.zIndex = '10000'; codeIcon.addEventListener('click', toggleEditor); document.body.appendChild(codeIcon); // 创建VSCode编辑器实例 let editor; // 添加检查Monaco资源可用性的函数 function checkMonacoAvailability(url) { return new Promise((resolve, reject) => { fetch(url) .then(response => { if (response.ok) { resolve(true); } else { reject(new Error('无法加载Monaco编辑器资源')); } }) .catch(error => { reject(error); }); }); } // 显示错误信息的函数 function showErrorMessage(message) { editorContainer.innerHTML = `
${message}
一般换一个网站就可以了。(比如下面几个)
有些严格网站会禁止访问 Monaco 编辑器的资源(来自 cdnjs.cloudflare.com)
比如 github.com 。
可以检查一下更新内容,说不准解决了呢 greasyfork.org
或者来我的博客看看: b.cornradio.org
看会儿视频放松一下: tva.cornradio.org