// ==UserScript== // @name mooc复制粘贴助手 // @namespace http://tampermonkey.net/ // @version 0.6 // @description 一键复制题目,便于笔记和整理。暂时不支持图片复制。 // @author shandianchengzi // @include https://www.icourse163.org/learn/* // @icon https://th.bing.com/th/id/R9f9f4fb2f36c5ed048b033efc79e7066?rik=GuAZZSaiqjDg1Q&riu=http%3a%2f%2fpic44.photophoto.cn%2f20170714%2f1190120161596932_b.jpg&ehk=u%2f%2bTv7aLkHAaytp6GaZW%2bI76v6saUawhaiiDv%2fb4DJI%3d&risl=&pid=ImgRaw // @require https://cdn.bootcdn.net/ajax/libs/crypto-js/4.0.0/core.js // @require https://cdn.bootcdn.net/ajax/libs/crypto-js/4.0.0/enc-base64.js // @require https://cdn.bootcdn.net/ajax/libs/crypto-js/4.0.0/md5.js // @require https://cdn.bootcdn.net/ajax/libs/crypto-js/4.0.0/evpkdf.js // @require https://cdn.bootcdn.net/ajax/libs/crypto-js/4.0.0/cipher-core.js // @require https://cdn.bootcdn.net/ajax/libs/crypto-js/4.0.0/aes.js // @license MIT // @grant none // @downloadURL none // ==/UserScript== var is_disable=0; function delAll(del=1,delClass=[],delId=[]){ let i,j; if(del==1&&delId.length){ //console.log("准备删除页面左侧栏……"); let leftdom=document.getElementsByClassName("m-learnleft"); if(leftdom.length) leftdom.forEach(function(dom){ dom.style.opacity='0.2'; }); //console.log("删除成功!"); } delClass.forEach(function(name){ //console.log("准备删除或隐藏指定Class名称的Dom元素……"); let namedom=document.getElementsByClassName(name); if(namedom.length) namedom.forEach(function(dom){ if(del==1){dom.remove();} else if(del==2){ if(is_disable==1){ dom.style.display='block'; }else{ dom.style.display='none'; } } }); //console.log("操作成功!"); }); if(delId.length) delId.forEach(function(name){ let dom =document.getElementById(name); if(dom){ if(del==1){dom.remove();} else if(del==2) { if(is_disable==1){ dom.style.display='block'; }else{ dom.style.display='none'; } } } }); if(del==2){ if(is_disable==1){ hideButton.value="DISABLE"; is_disable=0; hideButton.style.background='white'; } else{ hideButton.value="ABLE"; hideButton.style.background='pink'; is_disable=1; } } } var childList=[]; //循环获得某些Dom元素的子元素 function getDeepChildByOrder(limit){ let copyClass=["position","f-richEditorText","optionPos"],i,j; let copyId=[]; var child=limit.children; for(i=0;i setTimeout(resolve, time)); } function Toast(msg, duration) { let p1 = new Promise((resolve,reject)=>{ duration = isNaN(duration) ? 3000 : duration; var m = document.createElement('div'); m.innerHTML = msg; m.style.cssText = "font-family:siyuan;max-width:60%;min-width: 150px;padding:0 14px;height: 40px;color: rgb(255, 255, 255);line-height: 40px;text-align: center;border-radius: 4px;position: fixed;top: 50%;left: 50%;transform: translate(-50%, -50%);z-index: 999999;background: rgba(0, 0, 0,.7);font-size: 16px;"; document.body.appendChild(m); setTimeout(function() { var d = 0.5; m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in'; m.style.opacity = '0'; setTimeout(function() { document.body.removeChild(m) }, d * 1000); }, duration); }); } function unique (arr) { return Array.from(new Set(arr)) } function selectText(element) { if (document.createRange) { let range = document.createRange(); range.selectNodeContents(element); var selection = window.getSelection(); selection.removeAllRanges(); selection.addRange(range); } else { alert('none'); } } function createAButton(element,value,onclick,css,cla="temp",id="temp"){ let Button = document.createElement("input"); Button.type="button"; Button.value=value; Button.onclick=onclick; Button.setAttribute("style",css) ; Button.setAttribute("class",cla) ; Button.setAttribute("id",id) ; element.appendChild(Button); return Button; } function addTextWithBR(element,str){ var textNode,i; str=str.split(/[\n]/);//分割字符串 for(i=0;i0)getDeepChildByOrder(limit1[0]);} childList=unique(childList); //去除重复元素 //console.log(childList); for(let i=0;i