sync.lua
按下 Shift+F9 时将选中内容复制后同步到服务端。Shift+F8 时将服务端的内容粘贴到光标位置。
Windows 版使用 AutoHotKey v1 实现。如需加密,参考 AES-256-CBC PKCS7 SHA256 SALT PBKDF2 中 Hammerspoon 部分。
-- 远程剪贴板 hs.hotkey.bind( {'shift'}, 'f9', function() hs.eventtap.keyStroke({ "cmd" }, "c") local text = hs.pasteboard.readString() local encrypted = crypt(text, password) if encrypted then text = encrypted end local url = 'https://upall.cn/pasteboard/' local headers = { ['Content-Type'] = 'text/plain', } local code, body, headers = hs.http.post(url, text, headers) hs.alert.show("Pasteboard:" .. body) end ) hs.hotkey.bind( {'shift'}, 'f8', function() local url = 'https://upall.cn/pasteboard/' local code, body, headers = hs.http.get(url) local decrypted = crypt(body, password, false) if decrypted then body = decrypted end hs.pasteboard.setContents(body) hs.eventtap.keyStroke({ "cmd" }, "v") end )
server
error_reporting(0); $method = $_SERVER['REQUEST_METHOD']; if ($method == 'POST') { $data = file_get_contents("php://input"); $data or exit(); #file_put_contents('./plain.txt', "\n\n>>>>" . date('Y-m-d H:i:s') . "\n", FILE_APPEND); #$r = file_put_contents('./plain.txt', $data, FILE_APPEND); $r = file_put_contents('./plain.txt', $data); echo $r; } else if ($method == 'GET') { header('content-type: text/plain; charset=utf-8'); echo file_get_contents('./plain.txt'); } else { exit("unknown mehtod: $method"); }
注:移除加解密功能可以显著减小响应时间。如果你没有服务器,可以试试这个文本存储服务:textdb.dev。