日常用的ajax请求小脚本


function doA(a) {
	const id = a.attr("id");
	const idval = id.substring(5);
	console.log(idval)

		jQuery.ajax({
type : "POST",
contentType : "application/x-www-form-urlencoded;charset=utf-8",
data : {
"id" : idval
},
url : "/undo/sku/strategy",
dataType : "html",
success : function(_data) {
console.log(_data);
}
});
}




async function modifyApp(skuId) {

	// 第一步 抓取 id
	let info = await fetch(`//icorder.jd.com/find/sku/strategy/by/skuid?skuId=${skuId}&page.currentPage=1`, {
			"headers": {
			"accept": "application/json, text/plain, /",
			"accept-language": "zh-CN,zh;q=0.9",
			"x-requested-with": "XMLHttpRequest"
			},
			"body": null,
			"method": "GET",
			"credentials": "include"
			});
	// p返回p,
	let text = await info.text();

	jQuery(text).find('a[id^=undo]').each(function(){
			let undo =jQuery(this);
			if(undo.is(':hidden')) {
				doA(undo)
			}
			else {
				console.log(undo,"bukejian");
			}
	}) 

}

let skuIds =[100017176282,100009836741,100009836747,100009836739,100017176300];

for (let skuId of skuIds) {
	modifyApp(skuId)
}




async function modifyApp(app) {
// 第一步 抓取 id namespaceName name nameCn description language accessLevel labels projectEncoding ownerId
let info = await fetch(http://coding.jd.com/webapi/projects/app/${app}/info, {
“headers”: {
“accept”: “application/json, text/plain, /”,
“accept-language”: “zh-CN,zh;q=0.9”,
“x-requested-with”: “XMLHttpRequest”
},
“body”: null,
“method”: “GET”,
“mode”: “cors”,
“credentials”: “include”
});
let data = await info.json();
let body = {
id: data.id,
namespace: data.namespaceName,
name: data.name,
nameCn: data.nameCn,
description: data.description,
language: data.language,
accessLevel: 0,
labels: data.labels,
projectEncoding: data.projectEncoding,
ownerId: data.ownerId
}
// 第二步 请求修改
let actionResult = await fetch(http://coding.jd.com/webapi/projects/app/${app}/settings, {
“headers”: {
“accept”: “application/json, text/plain, /”,
“accept-language”: “zh-CN,zh;q=0.9”,
“content-type”: “application/json”,
“x-requested-with”: “XMLHttpRequest”
},
“body”: JSON.stringify(body),
“method”: “POST”,
“mode”: “cors”,
“credentials”: “include”
});
console.log(actionResult)
}

modifyApp(“order.main.task”)

(async () => {
try {
let res = await fetch(’./info.json’)
let data =await res.json()
console.log(‘data is:’,data);
} catch (error) {
console.log(error)
}
})()

// 简介

var GM_JQ = document.createElement(‘script’);

GM_JQ.src = ‘//ajax.aspnetcdn.com/ajax/jQuery/jQuery-1.7.2.js’;

GM_JQ.type = ‘text/JavaScript’;

document.getElementsByTagName(‘head’)[0].appendChild(GM_JQ);

四、

npm install -g http-server
http-server

npm install -g live-server
live-server

开发的时候推荐后者

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值