Last active
February 3, 2016 02:26
-
-
Save Ginhing/669caaf984f2e9f9ab3a to your computer and use it in GitHub Desktop.
用脚(本)订美团外卖
This file contains hidden or 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
// 从国内某知名企业 IM 的讨论界面开始运行以下语句 | |
var userAndlunch = e => e.querySelector('.message') && [e.querySelector('.user-name').textContent, e.querySelector('.message pre').textContent.trim().split('\n')[0]] | |
var lunchs = [].map.call($('.msg-box'), userAndlunch).filter(a => a && ~a[1].search(/^\$[^\$]*/)).map(a => a.join(':')) | |
JSON.stringify(lunchs, null, 2) | |
// 将上面输出的字符串复制,到美团商铺页面粘贴并赋值给全局变量 lunchs,再还行剩余所有语句 | |
var lunchNames = lunchs.map(str => str.replace(/^.*\:\$/, '')) | |
function addCart(foods, lunchNames) { | |
[].slice.call(foods).filter(e=> ~lunchNames.indexOf($(e).find('[title]').text().trim())) | |
.map(e => e.querySelector('.j-addcart')) | |
.forEach(e => e.click()) | |
} | |
addCart($('.j-pic-food'), lunchNames) | |
addCart($('.j-text-food'), lunchNames) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment