// ==UserScript==
// @name JD
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://item.jd.com/*
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
// Your code here...
var divObj=document.createElement("input");
divObj.type="button";
divObj.value='获取抓取内容';
divObj.style.marginTop="20px";
divObj.style.marginBottom="20px";
divObj.style.marginLeft="50px";
var first=document.body.firstChild;
document.body.insertBefore(divObj,first);
var result={};
divObj.onclick=function(){
//获取价格
if(document.getElementById("jd-price")){
var priceDiv=document.getElementById("jd-price");
var price = priceDiv.innerText;
price = price.substr(1);
}else if(document.getElementById("price")){
var pricePri=document.getElementById("price");
var priceDiv=pricePri.firstElementChild;
var price = priceDiv.innerText;
}else if(document.getElementsByClassName("price")[0]){
var priceClass=document.getElementsByClassName("price");
var priceDiv=priceClass[0];
var price = priceDiv.innerText;
}
result.price=price;
}
我不能帮你