Skip to content

Commit

Permalink
geosite: support Geo URL for website scanners
Browse files Browse the repository at this point in the history
If a website does not contain simple to extract coordinates, it might be
scanned for a Geo URL. The URL will be passed to the Add-On script where
the geourl lib can be used for parsing.
marcows committed Dec 28, 2018
1 parent 17e5e6e commit 1d12560
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions data/geosite.js
Original file line number Diff line number Diff line change
@@ -11,6 +11,7 @@
* @typedef {Object} GeositeInfo
*
* @property {GeoHackCoords} coords - map coordinates
* @property {String} url - Geo URL
*
* @global
*/
14 changes: 10 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
@@ -235,10 +235,16 @@ function updateShowmapButtonState()
// undefined to avoid outdated information.
geositeInfo = info;

// Only enable the state, do not disable it, this would lead to
// overwriting a state enabled by geourl.
if (geositeInfo)
setShowmapButtonState(true);
if (geositeInfo) {
// If not having direct coordinates, try the indirect way.
if (!geositeInfo.coords && geositeInfo.url)
geositeInfo.coords = geourl.parse(geositeInfo.url);

// Only enable the state, do not disable it, this would lead to
// overwriting a state enabled by geourl.
if (geositeInfo.coords)
setShowmapButtonState(true);
}
});
}

0 comments on commit 1d12560

Please sign in to comment.