Convert LF to CRLF

Automatically convert line feed (LF) to carriage return + line feed (CRLF) when copying text from web pages. 可以让复制的Greasy Fork镜像代码支持在via直接新建,也可以让系统菜单复制的通义千问移动端网页的代码在便签APP正常换行。UserScript完全由通义千问生成。

目前为 2024-04-21 提交的版本。查看 最新版本

// ==UserScript==
// @name         Convert LF to CRLF
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Automatically convert line feed (LF) to carriage return + line feed (CRLF) when copying text from web pages. 可以让复制的Greasy Fork镜像代码支持在via直接新建,也可以让系统菜单复制的通义千问移动端网页的代码在便签APP正常换行。UserScript完全由通义千问生成。
// @author       幸福的赢得
// @match        *://gf.qytechs.cn/*
// @match        *://update.gf.qytechs.cn/*
// @match        *://*.aliyun.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    document.addEventListener('copy', function(event) {
        var selection = window.getSelection().toString();
        if (!selection.includes('\n')) return;

        event.preventDefault();

        // Replace LF with CRLF
        var modifiedSelection = selection.replace(/\n/g, '\r\n');

        // Put the modified text on the clipboard
        event.clipboardData.setData('text/plain', modifiedSelection);
    });
})();

QingJ © 2025

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