Skip to content
This repository has been archived by the owner on Jul 30, 2018. It is now read-only.

Commit

Permalink
Works everywhere now
Browse files Browse the repository at this point in the history
  • Loading branch information
nhoizey committed Aug 3, 2015
1 parent af21503 commit fd6479f
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions Better500pxShowFavsUgly.user.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,29 @@
// @description Enhances 500px.com with fav indicators on thumbs
// @version 1.0.0
// @include https://500px.com/*
// @exclude https://500px.com/photo/*
// @exclude https://500px.com/fresh*
// @exclude https://500px.com/stories
// @exclude https://500px.com/blog
// @exclude https://500px.com/market*
// @exclude https://500px.com/upgrade
// ==/UserScript==

(function(window) {
var token = false,
userId = false;

jQuery("head").append("\
<style>\
.photo .fav { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; font-size: 14px; line-height: 1.1; text-align: center; overflow: hidden; }\
.photo .fav0 { background: rgba(128, 128, 128, .5); }\
.photo .fav1 { background: rgba(128, 255, 128, .8); color: #fff; }\
.photo .fav0 { background: rgba(128, 128, 128, .8); }\
.photo .fav1 { background: rgba(128, 255, 128, .9); color: #fff; }\
</style>\
");

setInterval(function loadPhotoInfos() {
jQuery('body.logged_in .photos .photo').not('.Better500pxShowFavs').not('.loading').slice(0, 1).each(function () {
jQuery('.photos div.photo, .container div.photo').not('.Better500pxShowFavs').not('.loading').slice(0, 5).each(function () {
var that = jQuery(this),
photoId = that.attr('data-photo-id');
photo = that.find('[data-ga-action="Title"]').eq(0),
photoUrl = photo.attr('href');
console.log(photoUrl);
that.addClass('loading');
jQuery.ajax({
dataType: "html",
url: 'https://500px.com/photo/' + photoId,
url: photoUrl,
context: that,
success: function(data) {
if (data.match(/,"favorited":true,/)) {
Expand All @@ -61,14 +56,14 @@
}
},
error: function (jqxhr, textStatus, error) {
console.log("Request Failed: " + textStatus + ", " + error);
// console.log("Request Failed: " + textStatus + ", " + error);
$(this).append('<div class="fav fav0">?</div>');
},
complete: function () {
$(this).addClass('Better500pxShowFavs').removeClass('loading');
}
});
});
}, 500);
}, 1000);
}(window));

0 comments on commit fd6479f

Please sign in to comment.