Last active
May 9, 2018 10:17
-
-
Save sempr/e6b446149a5daa0a4b603432c5f619a4 to your computer and use it in GitHub Desktop.
Coupons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 找券 | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match http*://item.taobao.com/item.htm* | |
// @match http*://detail.tmall.com/item.htm* | |
// @require https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js | |
// @grant GM_xmlhttpRequest | |
// @resource *://127.0.0.1:8000/* | |
// @resource *://coupon.me5.us/* | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var url = new URL(window.location.href); | |
var iid = url.searchParams.get("id"); | |
var get_domain="http://coupon.me5.us/"; | |
GM_xmlhttpRequest({ | |
method: "GET", | |
url: get_domain + "coupon/q/" + iid, | |
onload: function(res) { | |
var dat = JSON.parse(res.responseText); | |
if (+dat.success == 1){ | |
append_coupon(dat); | |
} | |
} | |
}); | |
var append_coupon = function(dat){ | |
var newnode = document.createElement("a"); | |
newnode.text = "有" + dat.coupon + "优惠券,点击领取"; | |
newnode.setAttribute("href", dat.coupon_url); | |
newnode.setAttribute("target", "_blank"); | |
newnode.setAttribute("style", "position: fixed; font-size:50px; z-index:999999999; top:200px; left:200px; background-color:cyan"); | |
newnode.onclick = function(event) { | |
newnode.setAttribute("style", "display: none;"); | |
}; | |
document.body.insertBefore(newnode, document.body.firstChild); | |
}; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment