标题: 我们站的代码没法直接复制 [打印本页]
作者: jyswjjgdwtdtj 时间: 2023-2-18 21:37 标题: 我们站的代码没法直接复制
现在复制复制代码
需要安装flash
但是很多人的电脑上已经没有flash了
一个innertext为什么还要flash呢?搞不明白
现在还得手动刷黑ctrl+c
作者: jyswjjgdwtdtj 时间: 2023-2-18 21:41
直接getelementbyid("code0").innertext不就行了?
作者: jyswjjgdwtdtj 时间: 2023-2-18 21:42
我看源代码里有个copycode函数,难道是这里用了flash?
我们吧也没什么动画,就算有也不用用flash老古董吧
作者: 我号被盗了 时间: 2023-2-19 19:16
回复 1# jyswjjgdwtdtj
承认,我还以为就我无法复制
作者: 老刘1号 时间: 2023-2-19 19:30
- // ==UserScript==
- // @name replace copy flash on Discuz
- // @name:zh-CN 替换Discuz的复制flash
- // @description Replace the "click here to copy" flash on Discuz
- // @description:zh-CN 替换Discuz论坛的"点此复制到剪贴板"flash
- // @namespace https://github.com/Testla
- // @version 0.9.1
- // @include http*://www.tsdm.me/*
- // @include http*://www.lightnovel.cn/*
- // @match http://*.bathome.net/*
- // @author Testla
- // @license MIT License
- // @compatible firefox 57 + Greasemonkey4/Tampermonkey tested
- // @compatible chrome + Tampermonkey
- // @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js
- // @grant GM.info
- // @grant GM.setClipboard
- // @grant GM_info
- // @grant GM_setClipboard
- // @grant unsafeWindow
- // ==/UserScript==
-
- (function() {
- 'use strict';
-
- // There are two versions available,
- // the non-privileged version doesn't use privileged API
- // but doesn't support Greasemonkey 4+
- // and may be incompatible with some old browsers
- // (check https://developer.mozilla.org/en-US/docs/Web/API/document/execCommand#Browser_compatibility).
- // To switch to the non-privileged version:
- // 1. remove all @require and @grant in the header
- // 2. add @grant none to the same place
- // 3. comment out the privileged version
- // 4. uncomment the non-privileged version
-
- // ---------------- BEGIN PRIVILEGED VERSION ----------------
- // If you only run on Greasemonkey 4+, you can remove the @require.
- // If you need not to run on Greasemonkey 4+,
- // you can remove the @require line together with the @grant GM.*s
- // and replace all "GM." with "GM_".
- // Note that the "@grant GM_*"s are required for Tampermonkey in Chrome
- // even if the corresponding "@grant GM.*"s and gm4-polyfill already exists,
- // please let me know if you can figure out why.
-
- function copyAndHint(text) {
- GM.setClipboard(text);
- // showPrompt comes with Discuz
- unsafeWindow.showPrompt(null, null, 'Copied', 3000);
- }
-
- function setCopy(text, hint) {
- copyAndHint(text);
- }
-
- function copycode(code_div) {
- copyAndHint(code_div.textContent);
- }
-
- var greasemonkey4OrGreater = GM.info.scriptHandler == 'Greasemonkey' &&
- parseFloat(GM.info.version) >= 4.0;
- if (greasemonkey4OrGreater) {
- // uses Firefox-specific hack
- // https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts
- exportFunction(copyAndHint, window, {defineAs:'copyAndHint'});
- window.eval(
- 'window.setCopy = function(text, hint) { copyAndHint(text); };' +
- 'window.copycode = function(code_div) { copyAndHint(code_div.textContent); };');
- } else {
- unsafeWindow.setCopy = setCopy;
- unsafeWindow.copycode = copycode;
- }
- // ---------------- END PRIVILEGED VERSION ----------------
-
- // ---------------- BEGIN NON-PRIVILEGED VERSION ----------------
- // var copyTextarea = document.createElement("textarea");
- // copyTextarea.style.width = "0px";
- // copyTextarea.style.height = "0px";
- // copyTextarea.style.position = "fixed";
-
- // // https://stackoverflow.com/questions/400212
- // function copyAndHint(text) {
- // document.body.appendChild(copyTextarea);
- // copyTextarea.textContent = text;
- // copyTextarea.select();
-
- // try {
- // var successful = document.execCommand('copy');
- // var msg = successful ? 'succeeded' : 'failed';
- // showPrompt(null, null, 'Copy ' + msg, 3000);
- // } catch (err) {
- // showPrompt(null, null, 'Oops, unable to copy', 3000);
- // console.log(err);
- // }
- // document.body.removeChild(copyTextarea);
- // }
-
- // window.setCopy = function(text, hint) {
- // copyAndHint(text);
- // };
-
- // window.copycode = function(code_div) {
- // copyAndHint(code_div.textContent);
- // };
- // ---------------- END NON-PRIVILEGED VERSION ----------------
-
- console.log('finished replacing Discuz\'s copy flash');
- })();
复制代码
作者: jyswjjgdwtdtj 时间: 2023-2-19 21:31
回复 5# 老刘1号
所以为啥要用flash啊
作者: 老刘1号 时间: 2023-2-19 22:46
回复 6# jyswjjgdwtdtj
这你得问batcher了,不是我的锅()
之前我也建议过给论坛加高亮、markdown、换掉flash啥的,都石沉大海了
这个站目前依然对ie6兼容()
作者: jyswjjgdwtdtj 时间: 2023-2-20 18:39
回复 7# 老刘1号
嘿 ie马上就要被微软灭掉了
作者: Batcher 时间: 2023-2-22 09:37
回复 1# jyswjjgdwtdtj
感谢对论坛的关心和建议。
目前论坛运行以稳为主,除了影响发帖、回帖等核心功能的情况,其他方面暂时不计划做调整。
有兴趣的朋友们可以试试:油猴脚本解决代码无法复制、TOP按钮不管用、代码高亮
http://bbs.bathome.net/thread-65254-1-1.html
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |