├── icon128.png ├── icon16.png ├── icon48.png ├── index.html ├── background.js ├── onboarding.html ├── manifest.json └── content-script.js /icon128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damiansire/Extension-Pedido-Ya/HEAD/icon128.png -------------------------------------------------------------------------------- /icon16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damiansire/Extension-Pedido-Ya/HEAD/icon16.png -------------------------------------------------------------------------------- /icon48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/damiansire/Extension-Pedido-Ya/HEAD/icon48.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 |

Esto es lo que se muestra al hacer click en la extension

3 | 4 | 5 | -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | chrome.action.onClicked.addListener((tab) => { 2 | chrome.scripting.executeScript({ 3 | target: { tabId: tab.id }, 4 | files: ['content-script.js'] 5 | }); 6 | }); 7 | 8 | -------------------------------------------------------------------------------- /onboarding.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | Document 9 | 10 | 11 | 12 |

Gracias por instalar mi extension bb

13 | 14 | 15 | -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Pedido ya extension - No oficial", 3 | "version": "1.0", 4 | "manifest_version": 2, 5 | "description": "Extension para buscar cosas baratas en pedido ya", 6 | "content_scripts": [ 7 | { 8 | "matches": [ 9 | "https://www.pedidosya.com.uy/*" 10 | ], 11 | "js": [ 12 | "content-script.js" 13 | ] 14 | } 15 | ], 16 | "icons": { 17 | "128": "icon128.png", 18 | "48": "icon48.png", 19 | "16": "icon16.png" 20 | }, 21 | "permissions": [ 22 | "activeTab", 23 | "storage" 24 | ], 25 | "short_name": "NombreCorto2", 26 | "author": "Damian Sire", 27 | "browser_action": { 28 | "default_popup": "index.html", 29 | "default_title": "Texto que se muestra al apoyar el mouse sobre el icono" 30 | } 31 | } -------------------------------------------------------------------------------- /content-script.js: -------------------------------------------------------------------------------- 1 | const config = { 2 | urlPedido: 'https://www.pedidosya.com.uy/mobile/v5/shopList?businessType=RESTAURANT&country=1&includePaymentMethods=VisaNet%2COCA%2CMastercard%20UY%2CTicket%20Restaurant%20Online%2CTicket%20Alimentaci%C3%B3n%20Online%2CCreditel%20UY%2CSpreedly%20UY&max=150&offset=0&point=-34.960163842831975%2C-54.94175160580445&sortBy=default&withFilters=true', 3 | headers: { 4 | 'authority': 'www.pedidosya.com.uy', 5 | 'method': 'GET', 6 | 'path': '/mobile/v5/shopList?businessType=RESTAURANT&country=1&includePaymentMethods=VisaNet%2COCA%2CMastercard%20UY%2CTicket%20Restaurant%20Online%2CTicket%20Alimentaci%C3%B3n%20Online%2CCreditel%20UY%2CSpreedly%20UY&max=30&offset=30&point=-34.960163842831975%2C-54.94175160580445&sortBy=default&withFilters=true', 7 | 'scheme': 'https', 8 | 'accept': 'application/json, text/plain, */*', 9 | 'accept-encoding': 'gzip, deflate, br', 10 | 'accept-language': 'es-ES,es;q=0.9', 11 | 'cookie': '__Secure-peya.sid=s%3A8e77ea4f-c44d-40c3-85b9-a561960ad0ba.rg2uwB1UwkW0yzq8ZwtNUeXsbFz6oVEl4vSrdoFuRzY; __Secure-peyas.sid=s%3Aa2f14117-0722-45d4-bb70-40027a2b9afe.TjePSABAu42vHlaCEiYHnhEtXWWVsIv8ZLN10RBclWE; _hjid=7b02bb3b-a809-43fc-aa5f-eee54fba37e9; _hjFirstSeen=1; _hjAbsoluteSessionInProgress=0; perseusRolloutSplit=7; dhhPerseusSessionId=1628902570235.500314316141730940.7y81739wvwn; dhhPerseusGuestId=1628902570235.76747974018306130.vdhj6zi5qe; _gcl_aw=GCL.1628902559.EAIaIQobChMI4d3r86av8gIViYORCh3grAfgEAAYASAAEgLGOPD_BwE; _gcl_au=1.1.793421776.1628902559; _fbp=fb.2.1628902559540.1932296122; AMP_TOKEN=%24NOT_FOUND; _ga=GA1.3.1214972178.1628902561; _gid=GA1.3.1084523346.1628902561; _gac_UA-68934388-1=1.1628902561.EAIaIQobChMI4d3r86av8gIViYORCh3grAfgEAAYASAAEgLGOPD_BwE; _gat_WD2_Tracker_PeYa_Prod=1; _tq_id.TV-81819090-1.49d8=f5ef121c4ef918f1.1628902561.0.1628902574..; dhhPerseusHitId=1628902598059.459130252231785700.cibnoc6e1ys', 12 | 'referer': 'https://www.pedidosya.com.uy/restaurantes?address=Gorlero&city=Punta%20del%20Este&lat=-34.960163842831975&lng=-54.94175160580445', 13 | 'sec-ch-ua': '"Chromium";v="92", " Not A;Brand";v="99", "Google Chrome";v="92"', 14 | 'sec-ch-ua-mobile': '?0', 15 | 'sec-fetch-dest': 'empty', 16 | 'sec-fetch-mode': 'cors', 17 | 'sec-fetch-site': 'same-origin', 18 | 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/92.0.4515.131 Safari/537.36', 19 | } 20 | } 21 | 22 | class Dao { 23 | 24 | static async getRestaurantData() { 25 | // Opciones por defecto estan marcadas con un * 26 | const response = await fetch(config.urlPedido, { 27 | method: 'GET', // *GET, POST, PUT, DELETE, etc. 28 | headers: config.headers, 29 | }); 30 | const responseJson = await response.json(); 31 | let restaurantResponse = responseJson.list.data; 32 | let restaurantData = restaurantResponse.map(restaurant => Parsers.ParserRestaurantData(restaurant)); 33 | console.log("Se trajieron ", responseJson.list.count, " restaurantes"); 34 | console.log("El total son ", responseJson.list.total) 35 | return restaurantData; 36 | } 37 | 38 | } 39 | 40 | class Parsers { 41 | static ParserRestaurantData(restaurant) { 42 | return { 43 | 'precioPromedio': restaurant?.averagePrice, 44 | 'categorias': restaurant?.categories, 45 | 'descuento': restaurant?.discount, 46 | 'distancia': restaurant?.distance, 47 | 'comida': restaurant?.food, 48 | 'speed': restaurant?.speed, 49 | 'name': restaurant?.name, 50 | 'link': restaurant?.link, 51 | 'logo': restaurant?.logo, 52 | 'deliveryTime': restaurant?.deliveryTime, 53 | 'shippingAmount': restaurant?.shippingAmount, 54 | 'service': restaurant?.service 55 | } 56 | } 57 | } 58 | 59 | class DrawUi { 60 | 61 | static setAveragePricesInWindows(restaurantData) { 62 | const allRestaurant = Array.from(document.querySelectorAll("#app > div > div.sc-72orc4-2.bMgRAV > div.sc-72orc4-1.eApoix > div > div.ygg9ap-0.hwDdoS > div.hfm867-0.hPTbWt > a")); 63 | allRestaurant.map(restaurant => { 64 | 65 | let restaurantName = restaurant.querySelector("#shop_card_result > div > div.sc-1n4iwls-1.efVtfo > div.zw4y2m-0.hVcPDG > div").innerText; 66 | 67 | let averagePrice = restaurantData.find(restaurant => restaurant.name == restaurantName).precioPromedio; 68 | 69 | const priceHtml = '
' + HtmlGenerator.priceSvg() + '' + averagePrice + '
'; 70 | 71 | const starsDiv = restaurant.children[0].children[0].children[2]; 72 | 73 | starsDiv.insertAdjacentHTML("beforeEnd", priceHtml); 74 | }) 75 | } 76 | 77 | static renderRestarantsData(restaurantData) { 78 | //Agrego un nuevo padre 79 | let divPadreDeLas2Columnas = document.createElement('div'); 80 | divPadreDeLas2Columnas.style.display = "flex"; 81 | divPadreDeLas2Columnas.id = "divPadreDeLas2Columnas"; 82 | let centerColumn = document.getElementsByClassName("hfm867-0 hPTbWt")[0]; 83 | HtmlGenerator.wrap(centerColumn, divPadreDeLas2Columnas) 84 | 85 | //selecciono el nuevo padre 86 | let newPadre = document.getElementById("divPadreDeLas2Columnas") 87 | 88 | //Inserto una columna para precio promedio 89 | newPadre.insertAdjacentHTML('beforeend', '
'); 90 | let restaurantsContainer = document.getElementById("precioPromedioColumn"); 91 | 92 | //Ordeno antes de renderizar 93 | restaurantData = restaurantData.sort((a, b) => { return a.precioPromedio - b.precioPromedio }); 94 | restaurantData.map(restaurant => restaurantsContainer.insertAdjacentHTML("beforeEnd", HtmlGenerator.restaurantHtml(restaurant))) 95 | } 96 | } 97 | 98 | class HtmlGenerator { 99 | 100 | static restaurantHtml(restaurant) { 101 | 102 | return ` 103 |
104 |
105 |
106 |
107 |
108 | 109 | 112 | ${restaurant.name} 118 | 119 |
120 |
121 |
122 |
123 |
${restaurant.name}
124 |
125 |
126 |
127 | ${restaurant.deliveryTime} 128 | 129 | ${this.getShippingAmount(restaurant)} 130 |
131 |
132 | ${this.starsDiv(restaurant.service)} 133 | 134 | ${this.htmlParaPrecioPromedio(restaurant)} 135 |
136 |
137 |
138 |
139 |
140 |
141 |
`; 142 | } 143 | 144 | static htmlParaPrecioPromedio(restaurantData) { 145 | return '
' + this.priceSvg() + '' + restaurantData.precioPromedio + '
'; 146 | } 147 | 148 | static starsDiv(startsNumber) { 149 | return '
' + startsNumber + '
'; 150 | } 151 | 152 | static getShippingAmount(restaurantData) { 153 | return restaurantData.shippingAmount ? `Envio $${restaurantData.shippingAmount}` : 'Envio Gratis'; 154 | } 155 | 156 | static priceSvg() { 157 | return ' ' 158 | 159 | } 160 | 161 | static wrap(toWrap, wrapper) { 162 | wrapper = wrapper || document.createElement('div'); 163 | toWrap.parentNode.appendChild(wrapper); 164 | return wrapper.appendChild(toWrap); 165 | }; 166 | 167 | } 168 | 169 | 170 | class ExtencionController { 171 | static async GetAndDrawAveragePricesInWindows() { 172 | const restaurantData = await Dao.getRestaurantData(); 173 | await DrawUi.setAveragePricesInWindows(restaurantData) 174 | } 175 | 176 | static async GetAndDrawColumnWithCheapRestaurant() { 177 | const restaurantData = await Dao.getRestaurantData(); 178 | DrawUi.renderRestarantsData(restaurantData); 179 | } 180 | 181 | } 182 | 183 | setTimeout(() => { 184 | ExtencionController.GetAndDrawColumnWithCheapRestaurant(); 185 | }, 6000) 186 | 187 | --------------------------------------------------------------------------------