From 11584e5a26e9760f7e419e4f049924e086af8a8e Mon Sep 17 00:00:00 2001 From: Jorge Bolois Guerrero Date: Sun, 16 Oct 2022 03:11:57 +0200 Subject: [PATCH] Adding altitude. Adding dark mode. --- locations/Bielsa.json | 1 + locations/Biescas.json | 1 + locations/Broto.json | 1 + locations/CastiellodeJaca.json | 1 + locations/Panticosa.json | 1 + locations/Sabiñanigo.json | 1 + locations/SallentdeGallego.json | 24 +++++++++++++ locations/Villanúa.json | 1 + locations/Zaragoza.json | 1 + src/App.js | 6 +++- src/Configuration.js | 1 + src/ConfigurationHTML.js | 5 +++ src/ItemHTML.js | 7 +++- src/Location.js | 3 ++ src/Preferences.js | 1 + src/Styles.js | 64 +++++++++++++++++++++++++++++++-- 16 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 locations/SallentdeGallego.json diff --git a/locations/Bielsa.json b/locations/Bielsa.json index 6dd3d8e..39c1d89 100644 --- a/locations/Bielsa.json +++ b/locations/Bielsa.json @@ -1,5 +1,6 @@ { "name": "Bielsa", + "altitude": 1034, "bus": true, "train": false, "pharmacy": null, diff --git a/locations/Biescas.json b/locations/Biescas.json index 756b3e1..35bef2a 100644 --- a/locations/Biescas.json +++ b/locations/Biescas.json @@ -1,5 +1,6 @@ { "name": "Biescas", + "altitude": 875, "bus": true, "train": false, "pharmacy": true, diff --git a/locations/Broto.json b/locations/Broto.json index 31caefc..470a548 100644 --- a/locations/Broto.json +++ b/locations/Broto.json @@ -1,5 +1,6 @@ { "name": "Broto", + "altitude": 905, "bus": false, "train": false, "pharmacy": true, diff --git a/locations/CastiellodeJaca.json b/locations/CastiellodeJaca.json index 67d8787..b90da6e 100644 --- a/locations/CastiellodeJaca.json +++ b/locations/CastiellodeJaca.json @@ -1,5 +1,6 @@ { "name": "Castiello de Jaca", + "altitude": 921, "bus": true, "train": false, "pharmacy": false, diff --git a/locations/Panticosa.json b/locations/Panticosa.json index 51cd000..500acbe 100644 --- a/locations/Panticosa.json +++ b/locations/Panticosa.json @@ -1,5 +1,6 @@ { "name": "Panticosa", + "altitude": 1184, "bus": true, "train": false, "pharmacy": true, diff --git a/locations/Sabiñanigo.json b/locations/Sabiñanigo.json index 18e7136..43b301a 100644 --- a/locations/Sabiñanigo.json +++ b/locations/Sabiñanigo.json @@ -1,5 +1,6 @@ { "name": "Sabiñanigo", + "altitude": 780, "bus": true, "train": true, "pharmacy": true, diff --git a/locations/SallentdeGallego.json b/locations/SallentdeGallego.json new file mode 100644 index 0000000..0551068 --- /dev/null +++ b/locations/SallentdeGallego.json @@ -0,0 +1,24 @@ +{ + "name": "Sallent de Gallego", + "altitude": 1305, + "bus": true, + "train": false, + "pharmacy": true, + "smoke": true, + "supermarkets": [ + { + "type": "ALCAMPO", + "url": "https://goo.gl/maps/JQVoBvucXwRMos8u9" + }, + { + "type": "CUSTOM", + "url": "https://goo.gl/maps/sPbbdQ6ENUcBgZC18" + }, + { + "type": "CUSTOM", + "url": "https://goo.gl/maps/sPbbdQ6ENUcBgZC18" + } + ], + "pool": true, + "gym": true +} \ No newline at end of file diff --git a/locations/Villanúa.json b/locations/Villanúa.json index 16f338a..87d5b8e 100644 --- a/locations/Villanúa.json +++ b/locations/Villanúa.json @@ -1,5 +1,6 @@ { "name": "Villanúa", + "altitude": 953, "bus": true, "train": true, "pharmacy": true, diff --git a/locations/Zaragoza.json b/locations/Zaragoza.json index 852ff9e..fabe89f 100644 --- a/locations/Zaragoza.json +++ b/locations/Zaragoza.json @@ -1,5 +1,6 @@ { "name": "Zaragoza", + "altitude": 243, "bus": true, "train": true, "pharmacy": true, diff --git a/src/App.js b/src/App.js index db3c2a9..526a74b 100644 --- a/src/App.js +++ b/src/App.js @@ -10,7 +10,11 @@ export default class App { static init() { Preferences.init(); - Styles.add(); + + Styles.add(Styles.APP_STYLES, 'midefos-idealista-app-styles'); + if (Preferences.get('darkMode')) { + Styles.add(Styles.DARK_MODE, 'midefos-idealista-dark-mode'); + } new Menu(); new Configuration(); diff --git a/src/Configuration.js b/src/Configuration.js index 13f333b..77ea501 100644 --- a/src/Configuration.js +++ b/src/Configuration.js @@ -42,6 +42,7 @@ export default class Configuration { const container = document.querySelector(ConfigurationHTML.CONTAINER_SELECTOR); return { enabled: container.querySelector('#enabled').checked, + darkMode: container.querySelector('#darkMode').checked, percentages: container.querySelector('#percentages').checked, percentages_20: container.querySelector('#percentages_20').checked, percentages_30: container.querySelector('#percentages_30').checked, diff --git a/src/ConfigurationHTML.js b/src/ConfigurationHTML.js index 2dafb1c..c890c5b 100644 --- a/src/ConfigurationHTML.js +++ b/src/ConfigurationHTML.js @@ -30,6 +30,11 @@ export default class ConfigurationHTML { ${CheckboxHTML.create('enabled', Preferences.get('enabled'))} Habilitado + +
diff --git a/src/ItemHTML.js b/src/ItemHTML.js index 28170b2..57763dc 100644 --- a/src/ItemHTML.js +++ b/src/ItemHTML.js @@ -180,7 +180,12 @@ export default class ItemHTML { } static _createLocationName(item) { - return this._createNeutral(item.locationName); + let html = `
` + html += this._createNeutral(item.locationName); + if (item.location?.altitude) this._createIndividual('Altitud (m):', item.location.altitude); + + html += `
` + return html; } static _createLocationTrain(item) { diff --git a/src/Location.js b/src/Location.js index ee68b1e..037ade8 100644 --- a/src/Location.js +++ b/src/Location.js @@ -5,6 +5,8 @@ export default class Location { static fromRaw(raw) { const location = new Location(); location.name = raw.name; + location.altitude = raw.altitude; + location.train = raw.train; location.bus = raw.bus; @@ -25,6 +27,7 @@ export default class Location { } name; + altitude; train; bus; diff --git a/src/Preferences.js b/src/Preferences.js index e25ac9f..6f9000b 100644 --- a/src/Preferences.js +++ b/src/Preferences.js @@ -43,6 +43,7 @@ export default class Preferences { static _default() { return { enabled: true, + darkMode: true, 'max-price': 120_000, 'max-price-per-meter': 1_500, diff --git a/src/Styles.js b/src/Styles.js index 8aacd24..302a9dd 100644 --- a/src/Styles.js +++ b/src/Styles.js @@ -98,13 +98,73 @@ export default class Styles { .${ConfigurationHTML.CONTAINER_CLASS_NAME} label { display: block; } + + /* Ads */ + .adv { + display: none; + } `; - static add(style = null) { - if (!style) style = this.APP_STYLES; + static DARK_MODE = ` + div.listing-top, + div.item-info-container, + section.links-block-home, + div.item-toolbar, + .links-block-home div.content, + div.wrapper, + picture.main-image, + .placeholder-multimedia, + section.module-contact, + .side-content .module-contact-gray, + .detail-pagination, + .rs-gallery-hud, .rs-gallery-header, + .rs-gallery-container .image-gallery .image-gallery-content, + .rs-gallery-footer, + .ide-box-detail, + section.ide-box-detail-first-picture, + .${ItemHTML.CONTAINER_CLASS_NAME}, + .${MenuHTML.CONTAINER_CLASS_NAME} { + background-color: #060703; + color: white; + } + + body, + #wrapper, + .new-listing-filter, + footer { + background-color: #181B0B; + color: white; + } + + .description, + .new-listing-filter a, + :root .input-radio > span > span, + :root .input-checkbox > span > span, + .home-boxes-container .draw-search, .home-boxes-container .put-property, .home-boxes-container .solidary-module { + color: white; + } + + .save-search-box { + color: black; + } + + .description::before { + display: none; + } + `; + + static add(style, id = null) { + if (id && document.querySelector(`#${id}`)) return; + const styleNode = document.createElement('style'); styleNode.textContent = style; + if (id) styleNode.id = id; document.head.appendChild(styleNode); } + static remove(id) { + const style = document.querySelector(`#${id}`); + if (style) style.remove(); + } + } \ No newline at end of file