// ==UserScript== // @name 小惠妹优惠券 - 快速领取淘宝、天猫优惠券 // @namespace http://www.xiaohuimei.com/ // @version 0.3 // @description 快速领取淘宝、天猫优惠券 // @author Minicocor // @match *://*.taobao.com/item.htm?* // @match *://detail.tmall.com/item.htm?* // @require http://cdn.bootcss.com/jquery/2.2.4/jquery.min.js // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; $(document).ready(function () { var host = window.location.host; var id = getQueryString("id"); var callurl = host + "?id=" + id; var productNm = ''; var addDom = ''; //debugger; if (host.indexOf('taobao.com') > 0) { productNm = $.trim($('.tb-main-title').text()); addDom = ".tb-action"; } else if (host.indexOf('tmall.com') > 0) { productNm = $.trim($('.tb-detail-hd h1').text()); addDom = ".tb-action"; } var apiurl = "http://localhost:50386/dataapi/SearchQuan?s="+productNm+"&callurl="+encodeURIComponent(callurl); apiurl = "http://localhost:50386/dataapi/SearchQuan"; apiurl = "http://www.xiaohuimei.com/search.html"; //apiurl = "http://localhost:50386/s.html"; apiurl = apiurl + "?s="+ encodeURIComponent(productNm)+"&callurl="+ encodeURIComponent(callurl); var clbl = "获取优惠券"; $(addDom).append(AppendHtml(host,apiurl,clbl)); }); function AppendHtml(host, url, clbl) { var ahlbl = "参加双11活动"; var ahurl = "#"; if (host.indexOf('taobao.com') > 0) { return '
'; } else if (host.indexOf('tmall.com') > 0) { return ' '; } else if (host.indexOf('jd.com') > 0) { return '' + clbl + ''; } } function getQueryString(name) { var reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)', 'i'); var r = window.location.search.substr(1).match(reg); if (r != null) { return decodeURI(r[2]); } return null; } })();