// ==UserScript== // @name 美团外卖菜单转换 // @namespace http://meituan.com // @version 0.0.1 // @description 获取美团外卖菜单页并指定格式输出 / Designed for my best university bro. // @include *://waimai.meituan.com/restaurant/* // @copyright 2016 // @downloadURL none // ==/UserScript== getMeituanMenu(); function getMeituanMenu() { const body = document.body; const btn = document.createElement('button'); btn.style.cssText = "position:fixed;z-index:100;left:0;bottom:400px;"; btn.innerHTML = "菜单信息/" body.appendChild(btn); const textarea = document.createElement('textarea'); textarea.style.cssText = "position:fixed;z-index:100;left:0;bottom:0px;height:380px;"; body.appendChild(textarea); btn.onclick = () => { let info = ''; const category = document.querySelectorAll('.food-nav .category'); for (let i = 0, categoryLength = category.length; i < categoryLength; i++) { const foodTypeName = category[i].querySelector('.title > span').textContent.trim(); info += "\n#" + foodTypeName + "\n"; const item = category[i].querySelectorAll('.pic-food'); for (let j = 0, itemLength = item.length; j < itemLength; j++) { const foodName = item[j].querySelector('.np .name').getAttribute('title').trim(); const foodPrice = item[j].querySelector('.labels .price .only').textContent.split('/')[0].substring(1).trim(); info += foodName + ' ' + foodPrice + '\n'; textarea.value = info; } } } }