🏠 Home 

OS#####JsonCopyer

OS#####在线JSON代码格式化工具 添加 一键复制


Install this script?
// ==UserScript==
// @name        OS#####JsonCopyer
// @author      rjw
// @description OS#####在线JSON代码格式化工具 添加 一键复制
// @namespace   com.uestc.rjw
// @icon        https://raw.githubusercontent.com/babyrjw/StaticFiles/master/logo_os#####.gif
// @license     Apache Licence V2
// @encoding    utf-8
// @date        18/10/2015
// @modified    18/10/2015
// @include     http://tool.os#####.net/codeformat/json
// @require     http://code.jquery.com/jquery-2.1.1.min.js
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_setClipboard
// @grant unsafeWindow
// @run-at      document-end
// @version     1.0.3
// ==/UserScript==
/*
* === 说明 ===
*@作者:rjw
*@Email:[email protected]
* */
var onekey = $('<input class="btn btn-small btn-primary" id="onkey_copy" type="button" onclick="copy_r###lt()" value="复制">');
$('#format').parent().append(onekey);
unsafeWindow.copy_r###lt = function copy_r###lt(){
var containerid = 'Canvas';
if (document.selection) {
var range = document.body.createTextRange();
range.moveToElementText(document.getElementById(containerid));
range.select();
} else if (window.getSelection) {
var range = document.createRange();
range.selectNode(document.getElementById(containerid));
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
}
try {
// Now that we've selected the anchor text, execute the copy command
var successful = document.execCommand('copy');
var msg = successful ? 'successful' : 'unsuccessful';
alert('Copy  ' + msg);
} catch(err) {
alert('Oops, unable to copy');
}
}