// ==UserScript== // @name 沃尔玛查询upc // @namespace http://tampermonkey.net/ // @version 0.5 // @description 在页面显示商品UPC码 // @author Take // @match *://www.walmart.com/ip/* // @match *://www.target.com/p/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // @downloadURL none // ==/UserScript== (function() { var www = window.location.host; var html = document.documentElement.outerHTML; var a,upc if(www == "www.walmart.com"){ a = html.indexOf('"upc":"'); console.log("沃尔玛"); var b = html.indexOf('","fetched"');//沃尔玛 upc = html.substring(a+7,b); }else{ a = html.indexOf('UPC'); upc = html.substring(a+9,a+21); } console.log("upc为:",upc); if(upc!="" && upc.length<=12){ var div = document.createElement("div"); div.innerHTML = "
UPC:"+upc+" Go>
"; document.body.appendChild(div); //window.open('https://www.amazon.com/s?k='+upc+'&ref=nb_sb_noss', '_blank'); } function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i