Skip to content

Commit

Permalink
geosite: support for Flickr photo site
Browse files Browse the repository at this point in the history
Does not work reliably:

1) Sometimes in Flickr's photostream feature (browsing through photos
with left/right buttons) on a photo site WITHOUT geo information, the
toggle button is enabled, but nothing happens when clicking.
Reason: On the first location change event, the Flickr map link from the
previous photo site WITH geo information is found, on the second event,
the DOM is updated and null is returned. Because of the asynchronous
nature of the content scripts, both results arrive after the two geourl
address bar checks (which are false), so the button is enabled by the
first wrong result, but not disabled by the second address bar check.
The second and correct result does not enable the button because this
race condition is not considered yet.
This behavior seems to occur always when switching from a photo site
WITH to a site WITHOUT geo information.

2) Sometimes on a photo site WITH geo information, the toggle button is
disabled. The DOM does not seem to be updated before the last event.
  • Loading branch information
marcows committed Jan 6, 2019
1 parent 0956820 commit a1ffb35
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
3 changes: 3 additions & 0 deletions data/geosite.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ var scanners = [
},{
func: scanGeosite_Wikivoyage,
urlpattern: /^https:\/\/[a-z.]+\.wikivoyage\.org\/wiki\//
},{
func: scanGeosite_Flickr,
urlpattern: /^https:\/\/www\.flickr\.com\/photos\//
},{
func: scanGeosite_GeoTag,
urlpattern: /^(https?|file):\/\//
Expand Down
26 changes: 26 additions & 0 deletions data/geosite/flickr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Part of content script {@link module:data/geosite}.
*/

/*
* Scanner for Flickr photo site.
*
* Prototype see {@link scanGeosite}.
*
* In websites:
* https://www.flickr.com/photos/53970209@N07/45705700935/
*/
function scanGeosite_Flickr()
{
var geoinfo;
var link;

link = document.querySelector(".map-container a[href]");

if (link) {
geoinfo = {};
geoinfo.url = link.href;
}

return geoinfo;
}
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ var mapcoords = require("./lib/mapcoords.js");
var geositeScripts = [
"./geosite/wikipedia.js",
"./geosite/wikivoyage.js",
"./geosite/flickr.js",
"./geosite/geotag.js",
"./geosite.js"
];
Expand Down

0 comments on commit a1ffb35

Please sign in to comment.