Skip to content

Commit

Permalink
v1.0.10 fixed pic.twitter.com
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralph Tice committed Jul 14, 2013
1 parent a4121df commit f8c3b69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 48 deletions.
3 changes: 1 addition & 2 deletions html/update-notif.html
Expand Up @@ -53,8 +53,7 @@
</head>
<body onload="init()">
<ul>
<li>Pulled in HoverZoom updates for default plugin, blogo.it, boardgamegeek, deviantart, e621, facebook, furaffinity, memefive, pictmobi, pinterest, pixiv, quora, sky.it, tumblr, wallbase.cc, youtube (thx Romain!)</li>
<li>removed defunct plugins (memegenerator, tagged), looks like G+ is fixed also</li>
<li>fixed pic.twitter.com links on twitter.com, woohoo!</li>
</ul>
<p id="footer">
<!--
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
@@ -1,6 +1,6 @@
{
"name":"Hover Free",
"version":"1.0.9",
"version":"1.0.10",
"description":"__MSG_extDescription__",
"manifest_version":2,
"icons":{
Expand Down
53 changes: 8 additions & 45 deletions plugins/twitter.js
Expand Up @@ -26,58 +26,21 @@ hoverZoomPlugins.push({
}
});

function getFromAPI(link, photoId) {
var linkData = link.data(),
storedUrl = localStorage['HZcache_' + photoId];
if (storedUrl) {
linkData.hoverZoomSrc = [storedUrl];
link.addClass('hoverZoomLink');
} else {
link.mouseenter(function () {
linkData.hoverZoomMouseOver = true;
if (linkData.hoverZoomTwitterApiCalled) {
return;
}
linkData.hoverZoomTwitterApiCalled = true;
$.getJSON('https://api.twitter.com/1/statuses/show.json?id=' + photoId + '&include_entities=true&trim_user=true',
function (data) {
if (data && data.entities && data.entities.media && data.entities.media.length) {
var media = data.entities.media[0],
url = (location.protocol == 'https:') ? media.media_url_https : media.media_url;

linkData.hoverZoomSrc = [url];
link.addClass('hoverZoomLink');

// Image is displayed if the cursor is still over the link
if (linkData.hoverZoomMouseOver)
hoverZoom.displayPicFromElement(link);

// URLs are stored to lessen API calls
localStorage['HZcache_' + photoId] = url;
}
}
);
}).mouseleave(function () {
linkData.hoverZoomMouseOver = false;
});
}
}

$('a:contains("pic.twitter.com/")').each(function () {
var link = $(this),
photoId = link.parents('[data-item-id]').attr('data-item-id');
if (photoId) {
getFromAPI(link, photoId);
}
var link = $(this);
var url = $(link.parent().parent().parent().data('expandedFooter')).find("a.media-thumbnail").data('url');
link.data().hoverZoomSrc = [url];
link.addClass('hoverZoomLink');
});

$('a[data-expanded-url*="/photo/"], a[data-full-url*="/photo/"]').each(function () {
/* $('a[data-expanded-url*="/photo/"], a[data-full-url*="/photo/"]').each(function () {
var link = $(this),
expandedUrl = link.attr('data-expanded-url') || link.attr('data-full-url'),
photoId = expandedUrl.replace(/.*status\/(\d+).*$/, '$1');
getFromAPI(link, photoId);
//getFromAPI(link, photoId);
link.addClass('hoverZoomLink');
});

*/
callback($(res));
}
});

1 comment on commit f8c3b69

@sarptas
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I now use version 1.0.12; but HoverFree still does not work on inline images in Twitter (i.e. pic.twitter.com)

Please sign in to comment.