Skip to content

Instantly share code, notes, and snippets.

View makeding's full-sized avatar

huggy makeding

View GitHub Profile
async function getLatestStableChromeUserAgent() {
const d = await axios.get('https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages')
if (d.data) {
let splitTemp = d.data.split('Package: google-chrome-stable\nVersion: ')
return `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/${splitTemp[1].split('\n')[0].split('.')[0]}.0.0.0 Safari/537.36`
}
}
export const generateRandomMac = (/* prefix = '' */) => {
// https://stackoverflow.com/questions/24621721/how-would-one-generate-a-mac-address-in-javascript
// https://en.wikipedia.org/wiki/MAC_address#Ranges_of_group_and_locally_administered_addresses
return 'XR:XX:XX:XX:XX:XX'.replace(/X/ig, (x) => {
return "0123456789ABCDEF"[Math.floor(Math.random() * 16)]
}).replace('R', '26AE'[Math.floor(Math.random() * 4)])
}
const uptimerobot_id = 'your uptimerobot_id'
const upstream = 'stats.uptimerobot.com'
const upstream_path = '/' + uptimerobot_id
const replace_dict = {
'$upstream': '$custom_domain',
@makeding
makeding / b23.js
Created February 19, 2021 16:08
b23 cloudflare worker
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
/**
* Respond to the request
* @param {Request} request
*/
async function handleRequest(request) {
let url = request.url.substr(8)
@makeding
makeding / app.js
Created November 12, 2020 12:03
check latest chrome version
# yarn add axios
# npm -i axios
let fs = require('fs')
let axios = require('axios')
let config = require('./config.json')
async function checkchromeversion() {
let system = ['Windows NT 10.0; Win64; x64', 'Windows NT 6.1; Win64; x64']
let data = await axios.get('https://dl.google.com/linux/chrome/deb/dists/stable/main/binary-amd64/Packages')
if (data.data) {
let v = data.data.split('\n')[1].split(' ')[1].split('-')[0]
@makeding
makeding / muc_login.js
Created September 23, 2020 04:07
中央民族大学 智慧门户 模拟登录
const rq = require('request-promise')
const url = 'http://ca.muc.edu.cn/zfca/login?service=http%3A%2F%2Fmy.muc.edu.cn%2Fuser%2FsimpleSSOLogin'
const ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.30 Safari/537.36'
async function run(username,password){
// 登录前要的两个数值 cookie lt
let {cookie,lt} = await new_pre_login_value()
let ticket_url,ticket,caUserName = false
let j = rq.jar()
await rq.post({
url: url,
let rqtest = (method, url, data, options) => {
uatest(options.ua)
}
let uatest = (ua = false) => {
console.log(ua)
}
rqtest('POST', 'xxx', {
type: 111
}, {
crypto: 'weapi',
@makeding
makeding / hitokoto_img.php
Created February 23, 2020 05:51
一言签名档
<?php
// download hitokoto.json from https://github.com/kokororin/hitokoto
$hitokoto = json_decode(file_get_contents('./hitokoto.json'),true);
$h = $hitokoto[array_rand($hitokoto)];
$hh = $h['hitokoto'];
$count = mb_strlen($hh,'UTF-8');
$height = $count * 27;
$width = 30;
$line = 1;
//换行还是有点bug 不想思考了
var request= require('request');
var fs= require('fs');
let user=['user']
let j = request.jar()
let usercookie=[];
for (var ii = 0; ii < user.length; ii++) {
let i=ii;
let loginurl="https://fujianlogin.safetree.com.cn/LoginHandler.ashx?userName="+user[ii]+"&password=123456&checkcode=&type=login&loginType=1"
request({url: loginurl, jar: j}, function () {
@makeding
makeding / luogu.js
Last active January 13, 2018 10:23
let request = require('request');
let cheerio = require('cheerio');
let fs = require('fs');
let tempurls = [];
let headers = {
'pragma': 'no-cache',
'dnt': '1',
'accept-encoding': 'gzip, deflate, br',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3319.0 Safari/537.36',