How to use key_D method in wpt

Best JavaScript code snippet using wpt

netease_music.js

Source:netease_music.js Github

copy

Full Screen

1const axios = require("axios")2const cheerio = require('cheerio')3const qs = require('qs')4const path = require('path')5let app = {6 sigObject: {7 key_g: "0CoJUm6Qyw8W8jud",8 key_f: "00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7",9 key_e: "010001",10 },11 getMusicInfo: (list) => {12 let result = [];13 if (!list) return result;14 list.forEach(item => {15 let singers = []16 item.ar.forEach(ar => {17 singers.push({18 name: ar.name,19 id: ar.id20 })21 })22 result.push({23 id: item.id, //id24 name: item.name, //歌曲名称25 albumName: item.al.name, //专辑26 one: false, //是否独占27 vip: item.copyright === 2, //是否需要vip或者无版权28 vid: item.mv === 0 ? null : item.mv, //mvId29 grp: null, //备选方案30 singer: singers,//歌手31 cover:item.al.picUrl, //32 source: path.parse(__filename).name33 })34 })35 return result;36 },37 evalScript: async () => {38 if (!app.__getSign) {39 let html = await axios.get(`https://music.163.com/#/song?id=${186064}`);40 let $ = cheerio.load(html.data);41 let scriptDom = $("script")42 let reg = /s3.music.126.net\/web\/s\/core_/;43 let url = null;44 for (let i = 0; i < scriptDom.length; i++) {45 let item = $(scriptDom[i]);46 let src = item.attr("src");47 if (reg.test(src)) {48 url = `https:${src}`;49 }50 }51 let data = (await axios.get(url)).data;52 //916253 let cryptoJS = data.match(/var CryptoJS.*\(Math\);/)[0]54 //958355 // let AES = data.match(/\(function\(\){.*u.AES=p.lQ8I\(d\)}\)\(\);/)[0];56 let AES = data.match(/\(function\(\).*u.AES.*}\)\(\)/)[0];57 //963558 let RSAKeyPairSc = data.match(/function RSAKeyPair.*}/)[0]59 //965960 let setMaxDigitsSc = data.match(/function setMaxDigits.*}/)[0]61 //989962 let varSet = data.match(/var maxDigits,.*\);/)[0]63 //990364 let signScript = data.match(/!function\(\).*}\(\);/)[0]65 signScript = signScript.replace(/window/g, "app.__net");66 // + setMaxDigitsSc + varSet + signScript67 eval(cryptoJS + ";" + AES + ";" + RSAKeyPairSc + setMaxDigitsSc + varSet + signScript)68 app.__getSign = app.__net.asrsea69 }70 },71 getSign: async (key_d) => {72 await app.evalScript();73 let sign = app.__getSign(JSON.stringify(key_d), app.sigObject.key_e, app.sigObject.key_f, app.sigObject.key_g);74 return qs.stringify({75 params: sign.encText,76 encSecKey: sign.encSecKey77 })78 },79 getMusicUrl: async (id) => {80 let key_d = {"ids": [], "level": "standard", "encodeType": "aac", "csrf_token": ""}81 key_d.ids.push(id)82 let key = await app.getSign(key_d);83 let req = await axios.post("https://music.163.com/weapi/song/enhance/player/url/v1", key)84 let urls = [];85 req.data.data.forEach(item => {86 urls.push(item.url)87 })88 return urls;89 },90 __getSign: null,91 __net: {},92 selectMusic: async (pageNumber, pageSize, word) => {93 let key_d = {94 "s": "",95 "type": "1",96 "offset": "0",97 "total": "true",98 "limit": "30",99 };100 pageNumber = pageNumber || 1101 pageSize = pageSize || 30102 key_d.s = word;103 key_d.offset = (pageNumber - 1) * pageSize104 key_d.limit = pageSize105 let key = await app.getSign(key_d)106 let rep = await axios.post("https://music.163.com/weapi/cloudsearch/get/web?csrf_token=", key)107 return app.getMusicInfo(rep.data.result.songs)108 },109 getMvUrl: async (id) => {110 let key_d = {"id": null, "r": "480", "csrf_token": ""}111 key_d.id = id112 let key = await app.getSign(key_d);113 let rep = await axios.post("https://music.163.com/weapi/song/enhance/play/mv/url?csrf_token=", key)114 return rep.data.data.url115 },116 getLyric: async (id) => {117 let key_d = {"id": null, "lv": -1, "tv": -1, "csrf_token": ""}118 key_d.id = id119 let key = await app.getSign(key_d);120 try {121 let rep = await axios.post("https://music.163.com/weapi/song/lyric?csrf_token=", key)122 return rep.data.lrc.lyric123 } catch (e) {124 console.log(e)125 }126 }127}128!async function init() {129 try {130 let url = await app.getMusicUrl(186064);131 if (url) {132 console.info(`netease-music=>${url}`)133 } else {134 console.log(`netease-music error`)135 }136 } catch (e) {137 console.log(`netease-music error`)138 console.error(e)139 }140}()...

Full Screen

Full Screen

keystrokes.js

Source:keystrokes.js Github

copy

Full Screen

1/*2 Keystrokes designed and programmed by CrafterL for krunker.io3 v.0.0.14*/56var keystrokes_style,keystrokes,key_w,key_a,key_s,key_d7var size = 18var x9var y1011document.addEventListener('DOMContentLoaded', () => {init()})1213function init() {14 keystrokes_style = document.createElement('style')15 keystrokes_style.id = 'keystrokes_style'16 document.body.appendChild(keystrokes_style)17 document.addEventListener('keydown', (key) => {18 if(document.getElementById('keystrokes')!=null){19 if(key.key === 'w') {key_w.style.backgroundColor = 'rgba(150,150,150, 0.3)'}20 if(key.key === 'a') {key_a.style.backgroundColor = 'rgba(150,150,150, 0.3)'}21 if(key.key === 's') {key_s.style.backgroundColor = 'rgba(150,150,150, 0.3)'}22 if(key.key === 'd') {key_d.style.backgroundColor = 'rgba(150,150,150, 0.3)'}23 }24 })25 document.addEventListener('keyup', (key) => {26 if(document.getElementById('keystrokes')!=null) {27 if(key.key === 'w') {key_w.style.backgroundColor = 'rgba(0,0,0, 0.3)'}28 if(key.key === 'a') {key_a.style.backgroundColor = 'rgba(0,0,0, 0.3)'}29 if(key.key === 's') {key_s.style.backgroundColor = 'rgba(0,0,0, 0.3)'}30 if(key.key === 'd') {key_d.style.backgroundColor = 'rgba(0,0,0, 0.3)'}31 }32 })33}34function create(val,val2,val3) {35 size = val36 x = val237 y = val338 keystrokes_style.innerHTML = 39 `40 #keystrokes {41 height: ${80*size}px;42 width: ${120*size}px;43 left: ${x*10}%;44 bottom: ${y*10}%;45 position: absolute;46 }47 .keystrokes_key {48 background-color: rgba(0,0,0, 0.3);49 height: ${49*size}%;50 width: ${32.5*size}%;51 position: absolute;52 line-height: 400%;53 text-align: center;54 font-size: ${20*size}px;55 color: white;56 }57 #key_w {58 margin-left: ${33.5*size}%;59 }60 #key_a {61 margin-top: ${33.5*size}%;62 }63 #key_s {64 margin-top: ${33.5*size}%;65 margin-left: ${33.5*size}%;66 }67 #key_d {68 margin-top: ${33.5*size}%;69 margin-left: ${67*size}%;70 }`71 keystrokes = document.createElement('div')72 keystrokes.id = 'keystrokes'73 key_w = document.createElement('div')74 key_w.id = 'key_w'75 key_w.className = 'keystrokes_key'76 key_w.innerHTML = 'W'77 key_a = document.createElement('div')78 key_a.id = 'key_a'79 key_a.className = 'keystrokes_key'80 key_a.innerHTML = 'A'81 key_s = document.createElement('div')82 key_s.id = 'key_s'83 key_s.className = 'keystrokes_key'84 key_s.innerHTML = 'S'85 key_d = document.createElement('div')86 key_d.id = 'key_d'87 key_d.className = 'keystrokes_key'88 key_d.innerHTML = 'D'89 keystrokes.append(key_w,key_a,key_s,key_d)90 document.getElementById('inGameUI').appendChild(keystrokes)91}92function changeSize(val) {93 size = val94 keystrokes.style.height = `${80*size}px`95 keystrokes.style.width = `${120*size}px`96 key_w.style.fontSize = `${20*size}px`97 key_a.style.fontSize = `${20*size}px`98 key_s.style.fontSize = `${20*size}px`99 key_d.style.fontSize = `${20*size}px`100 changePosition(x,y)101}102function changePosition(val,val2) {103 x = val104 y = val2105 if (x > 5) {keystrokes.style.left = `${x*10-((120*size/window.innerWidth*100)*((x-5)/5))}%`}106 else {keystrokes.style.left = `${(x*10)}%`}107 if(y > 5) {keystrokes.style.bottom = `${x*10-((80*size/window.innerHeight*100)*((x-5)/5))}%`}108 else {keystrokes.style.bottom = `${(y*10)}%`}109}110function XoffSet(val) {111 x = val112 changePosition(x,y)113}114function YoffSet(val) {115 y = val116 changePosition(x,y)117}118function remove() {119 if(keystrokes) {120 keystrokes.remove()121 keystrokes_style.innerHTML = ''122 }123} ...

Full Screen

Full Screen

cache.ts

Source:cache.ts Github

copy

Full Screen

1import { config } from '@helper/cache';2import { UserProps } from '@Types/user';3import mongodb from './mongodb';4import { connectToRedis } from './redis';5type Keys = keyof typeof config;6const { parse, stringify } = JSON;7class Cache {8 get config() {9 return config;10 }11 key(key: string, project = 'filmlist-gui-e') {12 return `${project}.${key}`;13 }14 get user() {15 return {16 get: async (id: string): Promise<UserProps> => {17 const redis = await connectToRedis();18 const cached = await redis.get(this.key(`user-${id}`));19 if (cached) {20 return parse(cached);21 } else {22 await mongodb.init();23 const u = await mongodb.userSchema.findOne({ $or: [{ identifier: id }, { token: id }] }).lean();24 await redis.set(this.key(`user-${id}`), stringify(u));25 return u;26 }27 },28 refresh: async (id: string): Promise<UserProps> => {29 const redis = await connectToRedis();30 await redis.del(this.key(`user-${id}`));31 const u = await this.user.get(id);32 return u;33 },34 };35 }36 async get<T>(key: Keys): Promise<T> {37 const key_d = config?.[key];38 const redis = await connectToRedis();39 const cached = await redis.get(this.key(key_d.key));40 if (cached) {41 return parse(cached);42 } else {43 const data: any = await key_d.data();44 await redis.set(this.key(key_d.key), stringify(data));45 return data;46 }47 }48 async refresh<T>(key: Keys) {49 const key_d = config?.[key];50 const redis = await connectToRedis();51 await redis.del(this.key(key_d.key));52 return await this.get<T>(key);53 }54 async flush() {55 const keys = Object.entries(this.config).map(([key, data]) => data.key);56 for (let i = 0; i < keys.length; i++) {57 console.log(keys[i]);58 await this.refresh(keys[i] as Keys);59 }60 return keys;61 }62 async forceFlush() {63 const redis = await connectToRedis();64 return await redis.flushall();65 }66 async stats() {67 const redis = await connectToRedis();68 return await redis.info();69 }70}71export const cache = new Cache();...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3 if (err) return console.error(err);4 console.log('Test Results for ' + data.data.url);5 console.log('First View (load time): ' + data.data.average.firstView.loadTime);6 console.log('Repeat View (load time): ' + data.data.average.repeatView.loadTime);7});8var wpt = require('webpagetest');9var wpt = new WebPageTest('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');10 if (err) return console.error(err);11 console.log('Test Results for ' + data.data.url);12 console.log('First View (load time): ' + data.data.average.firstView.loadTime);13 console.log('Repeat View (load time): ' + data.data.average.repeatView.loadTime);14});15var wpt = require('webpagetest');16var wpt = new WebPageTest('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef', {connection: '3gfast'});17 if (err) return console.error(err);18 console.log('Test Results for ' + data.data.url);19 console.log('First View (load time): ' + data.data.average.firstView.loadTime);20 console.log('Repeat View (load time): ' + data.data.average.repeatView.loadTime);21});22var wpt = require('webpagetest');23var wpt = new WebPageTest('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef', {location: 'Dulles:Chrome'});24 if (err) return console.error(err);25 console.log('Test Results for ' + data.data.url);26 console.log('First View (load time): ' + data.data.average.firstView.loadTime);

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org');3wpt.runTest(url, function(err, data) {4 console.log('SpeedIndex: ' + data.data.average.firstView.SpeedIndex);5 console.log('TTFB: ' + data.data.average.firstView.TTFB);6 console.log('Fully Loaded: ' + data.data.average.firstView.fullyLoaded);7});8var wpt = require('webpagetest');9var wpt = new WebPageTest('www.webpagetest.org');10wpt.runTest(url, function(err, data) {11 console.log('SpeedIndex: ' + data.data.average.firstView.SpeedIndex);12 console.log('TTFB: ' + data.data.average.firstView.TTFB);13 console.log('Fully Loaded: ' + data.data.average.firstView.fullyLoaded);14});15var wpt = require('webpagetest');16var wpt = new WebPageTest('www.webpagetest.org');17wpt.runTest(url, function(err, data) {18 console.log('SpeedIndex: ' + data.data.average.firstView.SpeedIndex);19 console.log('TTFB: ' + data.data.average.firstView.TTFB);20 console.log('Fully Loaded: ' + data.data.average.firstView.fullyLoaded);21});22var wpt = require('webpagetest');23var wpt = new WebPageTest('www.webpagetest.org');24wpt.runTest(url, function(err, data) {25 console.log('SpeedIndex: ' + data.data.average.firstView.SpeedIndex);26 console.log('TTFB: ' + data.data.average.firstView.TTFB);27 console.log('Fully Loaded: ' + data.data.average.firstView.fullyLoaded);28});29var wpt = require('webpagetest');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var api = new wpt('www.webpagetest.org');3 if (err) {4 console.log(err);5 } else {6 console.log(data);7 }8});9var wpt = require('webpagetest');10var api = new wpt('www.webpagetest.org');11 if (err) {12 console.log(err);13 } else {14 console.log(data);15 }16});17var wpt = require('webpagetest');18var api = new wpt('www.webpagetest.org');19 if (err) {20 console.log(err);21 } else {22 console.log(data);23 }24});25var wpt = require('webpagetest');26var api = new wpt('www.webpagetest.org');27 if (err) {28 console.log(err);29 } else {30 console.log(data);31 }32});33var wpt = require('webpagetest');34var api = new wpt('www.webpagetest.org');35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41var wpt = require('webpagetest');42var api = new wpt('www.webpagetest.org');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wptool = require('wptool');2var wp = new wptool();3wp.key_D(function(err, data){4 console.log(data);5});6var wptool = require('wptool');7var wp = new wptool();8wp.key_D(function(err, data){9 console.log(data);10});11var wptool = require('wptool');12var wp = new wptool();13wp.key_D(function(err, data){14 console.log(data);15});16var wptool = require('wptool');17var wp = new wptool();18wp.key_D(function(err, data){19 console.log(data);20});21var wptool = require('wptool');22var wp = new wptool();23wp.key_D(function(err, data){24 console.log(data);25});26var wptool = require('wptool');27var wp = new wptool();28wp.key_D(function(err, data){29 console.log(data);30});31var wptool = require('wptool');32var wp = new wptool();33wp.key_D(function(err, data){34 console.log(data);35});36var wptool = require('wptool');37var wp = new wptool();38wp.key_D(function(err, data){39 console.log(data);40});41var wptool = require('wptool');42var wp = new wptool();43wp.key_D(function(err, data){44 console.log(data);45});46var wptool = require('wptool');47var wp = new wptool();48wp.key_D(function(err, data){49 console.log(data);50});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run wpt automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful