您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
try to take over the world!
当前为
// ==UserScript== // @name 扩展设计器网页审核回复模版 // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://ext.mblock.cc/ // @match https://ext.makeblock.com/ // @grant none // ==/UserScript== (function() { 'use strict'; // Your code here... //add css let style = document.createElement('style'); let csss = ` .button-reply {z-index: 1;} .aside { padding: 105px 0 20px; background: white; width: 300px; height: 100%; position: fixed; right: 0; top: 0; transform: translateX(100%); transition: transform .4s; z-index: 2; box-shadow: -2px 2px 5px 0 rgba(0,0,0,.4); overflow-y: auto; } .aside.active {transform: translateX(0%);} .each-rw {padding: 15px 15px; border-bottom: 1px solid rgba(0,0,0,0.1); cursor: pointer;} .each-rw:hover {background: #f2f8ff;} .hint {color: #b2b2b2;} .copiedPrompt {position: absolute; left: 10px; top: 70px; color: red; opacity: 0;} .copiedPrompt.active {opacity: 1;} ` style.innerText = csss; document.head.appendChild(style); //mock data /* let data = [{ text: 'Congrats! You could create demos based on your extension in the community: http://planet.mblock.cc/, and then paste the demo work link into your "extesion homepage" section in the extension builder.', hint: "当用户扩展审核通过时" },{ text: "Congrats your extension passed. However, please add more content (like blocks) for your extension to make it better and more interesting for users of mBlock", hint: "当扩展积木较少,但是没有大问题时" },{ text: "Congrats your extension passed. However, please choose a meaningful cover that is more related to the functionality of your extension. This will help others know what your extension is about.", hint: "当扩展没有大问题,但封面图片不相关或者无实际意义时" },{ text: "Congrats! However, please add more details for your next update. We will release an extension market soon, those description will be important as your extension info.", hint: "当扩展没有大问题,但更新说明过于简短时" },]; let zhData = [{ text: '审核通过!如果想让更多人学会使用您的扩展,可以到作品社区使用您的扩展创建作品,展示如何使用您的扩展:http://mblock.makeblock.com/ 然后可以在扩展设计器中将作品主页链接更新到扩展主页一栏,方便使用者查看案例', hint: "当用户扩展审核通过时" },{ text: "恭喜您的扩展审核通过,但是内容仍然需要一定程度的完善和丰富,建议您可以多增加一些积木。", hint: "当扩展积木较少,但是没有大问题时" },{ text: "恭喜您的扩展审核通过,但是出于扩展展示的目的,请您为自己的扩展更换更合适,更能表现您扩展特色,以及增加扩展吸引力的封面", hint: "当扩展没有大问题,但封面图片不相关或者无实际意义时" },]; */ // console.log("you‘re using扩展设计器网页脚本") let aside = document.createElement('div'); /*侧边栏*/ aside.classList.add('aside'); document.body.appendChild(aside); let asideState = false /*侧边栏状态*/ let copiedPrompt = document.createElement('p'); /*已复制 提示文字*/ copiedPrompt.classList.add('copiedPrompt'); copiedPrompt.textContent = '已复制到剪切板!' let btnEl = document.createElement('button'); /*弹出按钮*/ btnEl.textContent = '回复模版' btnEl.classList.add('button-reply') btnEl.classList.add('ant-btn') btnEl.classList.add('ant-btn-primary') btnEl.classList.add('ant-btn-lg') console.log(btnEl) btnEl.style.position = 'fixed'; btnEl.style.top = '60px'; btnEl.style.right = '20px'; btnEl.style.zIndex = '999'; document.body.appendChild(btnEl); btnEl.addEventListener('click', ()=>{ switchPopState(asideState); asideState = !asideState; }) //将数据放入侧边栏中 let els = document.createDocumentFragment(); fetch('https://hobart.avosapps.us/api/audit/content/query') .then(e=>e.json()) .then((e)=>{ console.log(e) let {data} = e; dataToDOM(data) aside.appendChild(copiedPrompt) aside.appendChild(els) }) /* *评论数据DOM渲染 */ function dataToDOM(data){ data.forEach(e=>{ let el = document.createElement('div'); el.classList.add('each-rw'); let text = document.createElement('p'); let hint = document.createElement('p'); hint.classList.add('hint') text.textContent = e.text; hint.textContent = '注: '+e.hint; el.title = '点击以复制到剪切板'; el.appendChild(text); el.appendChild(hint); els.appendChild(el); el.addEventListener('click', ()=>{ copyText(e.text, ()=>{ copiedPrompt.classList.add('active'); let id = setTimeout(()=>{ copiedPrompt.classList.remove('active'); window.clearTimeout(id); },3000) }) }) }) } /* *切换侧边栏弹出方法 */ function switchPopState(state){ if(state) { aside.classList.add('active') btnEl.innerText = '关闭' }else{ aside.classList.remove('active') btnEl.innerText = '回复模版' } } /*复制到剪切板*/ function copyText(text, callback){ // text: 要复制的内容, callback: 回调 var tag = document.createElement('input'); tag.setAttribute('id', 'cp_hgz_input'); tag.value = text; document.getElementsByTagName('body')[0].appendChild(tag); document.getElementById('cp_hgz_input').select(); document.execCommand('copy'); document.getElementById('cp_hgz_input').remove(); if(callback) {callback(text)} } })();