您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
a private tool
当前为
// ==UserScript== // @name word copy demo🔧 // @description a private tool // @namespace word_copy_tool_demo // @author Covenant // @version 1.0 // @license MIT // @homepage // @match *://*/* // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADQAAAA0CAMAAADypuvZAAAAPFBMVEUAAACvDwOyDwKyDwOvEACyDgOyDwKvDwKwDgCyDgKxDgOyDgKvDgKyDwKyDgOxDgKzDgKxDgKxEASyDwMgW5ZmAAAAE3RSTlMAQN+/EJDvMB9wYJ9Qz7CAf6CAtGoj/AAAAcFJREFUSMeVltu2gyAMRLlfBDxt+f9/PTq2VXSwmod2GdhkEoIiiPmYinK1VqXt4MUFk9bVxlTyvxBdienhNoJwoYMY+57hdMzBTA4v4/gRaykT1FuLNI0/j/1g3i2IJ8s9F+owNCx+2UlWQXbexQFjjTjN1/lGALS9xIm9QIXNOoowlFKrFssYTtmvuOXpp2HtT6lUE3f11bH1IQu9qbYUBEr7yq8zCxkWuva8+rtF4RrkP6ESxFPoj7rtW30+jI4UQlZuiejEwZ4cMg65RKjjUDz6NdwWvxw6nnLESEAl230O5cldUAdy8P44hJZTYh40DOIKzFw3QOI6hPk9aDiFHJc3nMirKERgEPd7FKKgiy5DEn3+5JsrAfHNtfjVRLucTPTaCA1rxFVz6AX8yYsIUlXoMqbPWFUeXF1Cyqz7Ej1PAXNBs1B1tsKWKpsX0yFhslTetL4mL8s4j2fyslTbjbT7Va2V7GCG5ukhftijXdsoQhGmzSI4QhHGhVufz4QJ/v6Hug6dK0EK3YuM8/3Lx5h3Z0STywe55oxRejM5Qo4aAtZ8eTBuWp6dl3IXgfnnLpyzBCFctHomnSopejLhH/3AMfEMndTJAAAAAElFTkSuQmCC // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_listValues // @connect // @run-at document-end // @noframes // ==/UserScript== var div_fixed; var input_word; var select_idx; var input_num; var btn_copy; var p_console_log; var novel_text_raw="_null"; function create_style(textContent,id,class_name){ let style=create_node("style",class_name,true,document.body); style.type='text/css'; style.id=id; style.textContent=textContent; return style; } const font_family_panel="font-family: 'Noto Sans Mono','Noto Mono','Consolas','DroidSans_Mono','symbol_emoji','Noto Color Emoji','Noto Sans CJK JP','Meiryo','Yu Gothic','Microsoft JhengHei','old_emoji',sans-serif"; var style_font_face=create_style("@font-face{font-family: 'color_emoji';src: local('Segoe UI Emoji'),local('Noto Color Emoji');}\n","gm_font_face_word_copy_demo",["user_gm_css","css_word_copy_demo"]); style_font_face.textContent+=`@font-face{font-family: 'symbol_emoji';src: local('Segoe UI Symbol');}\n@font-face{font-family: 'old_emoji';src: local('Noto Color Emoji');} @font-face{font-family: 'DroidSans_Mono';src: local('DroidSansMono');}\n@font-face{font-family: 'Cutive_Mono';src: local('Cutive Mono');} @font-face{font-family: 'Roboto_2';src: local('Roboto');}\n@font-face{font-family: 'Noto_Serif';src: local('NotoSerif');}\n@font-face{font-family: 'Dancing_Script';src: local('DancingScript');}\n`; var style_user_css=create_style(".user_input_fixed,.p_console_log{"+font_family_panel+" !important; font-weight: 300;}\n","gm_user_css_word_copy_demo",["user_gm_css","css_word_copy_demo"]); style_user_css.textContent+=`input.user_input_fixed{width: auto;max-width: 95%;border-radius: 0.5rem; font-size: 110%;padding: 0.25em;max-height: 2em;} .user_div_fixed_novel{background: #00000033;display: flex;justify-content: flex-end;flex-wrap: wrap;min-width: 100%;} div.div_br{width: 100%;}\n.user_div_fixed_novel{position:fixed !important;z-index: 65535;top: 20%;right: 0px;} .input_querySelectorAll_novel{min-width: 25%;}\n.p_console_log{background: #00000080;} .user_select_fixed{font-size: 0.75rem;padding: 0.25rem;min-width: 5em;max-width: 7em;} .user_btn_margin{margin-right: 2px;margin-left: 3px;margin-top: 1px;margin-bottom: 1px;padding-left: 5px;padding-right: 5px;} .user_btn_panel_fixed{min-width: 5em;min-height: 1em;max-height: 2em;`+font_family_panel+` !important;font-weight: 100;} input[type="checkbox"].user_checkbox~label{margin-right: 0.5em;cursor: pointer;}\ndiv.div_checkbox{min-width: 2em;background: #00000080;}\ndiv.user_checkbox_inline{display: inline-block;}`; function create_div(class_name,is_appendChild,node,refNode){ let div=create_node("div",class_name,is_appendChild,node,refNode); div.style.backgroundSize='contain'; div.style.backgroundRepeat='no-repeat'; div.lang='ja'; return div; } function create_input(placeholder,class_name,is_num,is_appendChild,node,refNode){ let input=create_node("Input",class_name,is_appendChild,node,refNode); input.placeholder=placeholder; input.type="text"; if(is_num)input.size="10"; if(is_num)input.setAttribute("maxlength", "10"); if(is_num)input.setAttribute("oninput","this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\\..*?)\\..*/g, '$1');"); return input; } function create_btn(innerText,class_name,is_appendChild,node,refNode){ let btn=create_node("button",class_name,is_appendChild,node,refNode); btn.innerText=innerText; return btn; } function create_select(class_name,is_multiple,size,is_appendChild,node,refNode){ let select=create_node("select",class_name,is_appendChild,node,refNode); select.setAttribute("multiple", is_multiple); select.setAttribute("size", size); return select; } function create_checkbox(innerText,id,class_name,is_block,is_checked,is_appendChild,node,refNode){ const div_class=is_block?"div_checkbox":["div_checkbox","user_checkbox_inline"]; let div=create_div(div_class,is_appendChild,node,refNode); let input=document.createElement("Input"); input.type="checkbox"; input.id="cb_"+id; input.value=id; if(is_checked==true)input.checked=true; if(Array.isArray(class_name)){ for(let i=0; i<class_name.length; i++){ input.classList.add(class_name[i]); } }else if(typeof class_name==='string'){ input.classList.add(class_name); } div.appendChild(input); let lbl=create_node_text("label",innerText,"user_lbl",true,div); lbl.htmlFor=input.id; return input; } function create_node(tagname,class_name,is_appendChild,node,refNode){ let element=document.createElement(tagname); if(Array.isArray(class_name)){ for(let i=0; i<class_name.length; i++){element.classList.add(class_name[i]);} } else if(typeof class_name==='string'){element.classList.add(class_name);} if(is_appendChild){node.appendChild(element);}else{node.insertBefore(element, refNode);} return element; } function create_node_text(tagname,innerText,class_name, is_appendChild,node,refNode){ let element = create_node(tagname, class_name, is_appendChild, node, refNode); element.innerText=innerText; return element; } function console_log_tmp(text,bool){ let div_log=p_console_log; div_log.innerHTML+=text; if(bool){div_log.innerHTML=text;} } function fn_remove_multiple_line_breaks(str){//questions/22962220 return str.replace(/(\r\n|\r|\n){2}/g, '$1').replace(/(\r\n|\r|\n){3,}/g, '$1\n'); } //console.log("break"); function fn_char2u(char){ return "\\u"+("0000"+char.charCodeAt(0).toString(16)).slice(-4); } function fn_querySelectorAll(){ try{ let node=document.querySelectorAll(input_word.value); if(node.length>0){ select_idx.innerText=""; for(let i=0; i<node.length>0; i++){ let option=create_node("option",[], true, select_idx); option.innerText=option.value=i; } } else if(node.length==0){ select_idx.innerText=""; let option=create_node("option",[], true, select_idx); option.innerText="null"; option.setAttribute("disabled", true); } }catch(e){ console_log_tmp(e.message,true); }finally{} } function fn_select_idx(){ input_num.value=select_idx.value; } function fn_btn_copy(){ console_log_tmp("",true); try{ let node=document.querySelectorAll(input_word.value); if(node.length>0){ let index=input_num.value==""?0:parseInt(input_num.value); index=node.length>index?index:0; novel_text_raw=fn_remove_multiple_line_breaks(node[index].innerText); btn_copy.innerText="copy "+novel_text_raw.length+";"; let str_debug=novel_text_raw.substring(0,7); for(let i=0; i<str_debug.length>0; i++){ console_log_tmp(fn_char2u(str_debug[i])); } } else if(node.length==0){ novel_text_raw="_null"; btn_copy.innerText="copy null"; } navigator.clipboard.writeText(novel_text_raw); console_log_tmp(" "+node.length); }catch(e){ console_log_tmp(e.message,true); }finally{} } (function() { 'use strict'; let panel=GM_getValue('panel', false); let selector=GM_getValue('selector', ""); GM_registerMenuCommand('💬input;', () => { panel=!panel; GM_setValue('panel', panel); if(panel){div_fixed.style.removeProperty("display");}else{div_fixed.style.display="none";} }); //div fixed ui div_fixed=create_div(["user_div_fixed_novel"],false,document.body,document.body.firstChild); input_word=create_input("font-family: !important",["user_input_fixed","input_querySelectorAll_novel"],false,true,div_fixed); create_div("div_br",true,div_fixed); p_console_log=create_node("p","p_console_log",true,div_fixed); btn_copy=create_btn("copy",["user_btn_panel_fixed","user_btn_margin"],true,div_fixed); select_idx=create_select("user_select_fixed",true,"5", true, div_fixed); input_num=create_input("font-weight: !important","user_input_fixed",true,true,div_fixed); create_div("div_br",true,div_fixed); if(panel){div_fixed.style.removeProperty("display");}else{div_fixed.style.display="none";} // input_word.value=selector; input_num.value=0; console_log_tmp(GM_listValues()+" "+panel,true); // input_word.addEventListener("input", function (e) {fn_querySelectorAll();}); fn_querySelectorAll(); select_idx.addEventListener("input", fn_select_idx); btn_copy.addEventListener('click',() => { fn_btn_copy(); navigator.clipboard.writeText(novel_text_raw); }); /*input_word.addEventListener("keyup", function(e){ });//*/ window.addEventListener("beforeunload", (event) => { // set a truthy value to property returnValue GM_setValue('selector', input_word.value); }); })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址