[煎蛋]jandan-helper

解锁煎蛋文字复制功能,让地球上信息传递没有障碍。

// ==UserScript==
// @id           [email protected]
// @name         [煎蛋]jandan-helper
// @namespace    https://github.com/ctgnauh
// @version      0.1
// @description  解锁煎蛋文字复制功能,让地球上信息传递没有障碍。
// @author       Tristan Huang
// @match        http://jandan.net/*/*/*/*.html
// @grant        none
// ==/UserScript==
/* jshint -W097 */
'use strict';

var selected = '';

document.addEventListener('mouseup', function() {
    selected = window.getSelection().toString();
});

document.addEventListener('copy', function() {
    var selection = window.getSelection(),
        olddiv = document.createElement('div');
    olddiv.style.position = 'absolute';
    olddiv.style.left = '-99998px';

    document.body.appendChild(olddiv);
    olddiv.innerHTML = selected;
    selection.selectAllChildren(olddiv);
    window.setTimeout(function () {
        document.body.removeChild(olddiv);}, 100);
});

QingJ © 2025

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