您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
使用pageId生成对应的小程序体验码
当前为
// ==UserScript== // @name 小程序体验码生成 // @namespace medivh // @version 0.1 // @description 使用pageId生成对应的小程序体验码 // @author You // @match http://ling-test.jd.com/atom_v2/h5/app/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // ==/UserScript== (function() { 'use strict'; function getQueryVariable(variable){ const query = window.location.search.substring(1); const vars = query.split("&"); for (let i=0;i<vars.length;i++) { const pair = vars[i].split("="); if(pair[0] == variable){return pair[1];} } return(false); } function run () { const container = document.querySelector('.app_container') const pageId = getQueryVariable('pageId') const appId = window.location.href.includes('/atom_v2/h5/app/') ? 'wxdefc7950d76a40bd' : 'wx5ccdbece47b04474' const qrcodeUrl = `https://open.weixin.qq.com/sns/getexpappinfo?appid=${appId}&path=pages%2Findex%2Findex.html%3FpageId%3D${pageId}%26isPreview%3D1#wechat-redirect` const qrCodeDom = document.createElement('iframe') qrCodeDom.src = `https://cli.im/api/qrcode/code?text=${qrcodeUrl}` qrCodeDom.style.cssText=` position: fixed; top: 50%; right: 200px; transform: translateY(-50%);` qrCodeDom.width = 500 qrCodeDom.height = 500 container.appendChild(qrCodeDom) const showBtnDom = document.getElementById('plugin-make-qrcode-btn') showBtnDom.innerText='关闭弹窗' showBtnDom.onclick=() => { container.removeChild(qrCodeDom) showBtnDom.innerText = '生成体验码' showBtnDom.onclick = run } } setTimeout(() => { const mainDom = document.querySelector('.app_container') const showBtn = document.createElement('div') showBtn.innerText = '生成体验码' showBtn.id='plugin-make-qrcode-btn' showBtn.style.cssText = `position: fixed; top: 20px; right: 40%; height: 32px; line-height: 32px; background: #2d68ff; padding: 0 10px; color: #fff; border-radius: 30px; cursor: pointer; z-index: 2;` showBtn.onclick = run mainDom.appendChild(showBtn) }, 2000) })();