// ==UserScript== // @name 玩转CSDN // @namespace http://tampermonkey.net/ // @version 0.1000 // @match *://blog.csdn.net/* // @icon https://source.unsplash.com/random // @description 仅供参考学习 // @author wwwbh // @icon https://www.google.com/s2/favicons?domain=csdn.net // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; function copy(signElem) { let codeelem = null; try{ codeelem = signElem.parentNode; if(codeelem.id.indexOf('code')===-1){ throw new EvalError('value error',lineNumber=22); } }catch(err){ codeelem = signElem.previousSibling; } document.oncopy=function(e){ e.clipboardData.setData('text',codeelem.innerText); e.preventDefault(); document.oncopy=null; } document.execCommand("Copy"); signElem.setAttribute('data-title','复制成功'); signElem.style.cssText += 'background-color: green'; setTimeout(()=>{ signElem.setAttribute('data-title','点击复制'); signElem.style.removeProperty('background-color','green'); },1000); }; let codes = document.querySelectorAll('#content_views pre code'); let signs = document.querySelectorAll('.signin'); for(var i=0;i