Last active
December 21, 2015 15:39
-
-
Save joshuabaker/6328230 to your computer and use it in GitHub Desktop.
At the time of publishing Digg Reader doesn’t have a simple batch unsubscribe method. This is the source for a bookmarklet that adds a delete button to feed items. Get the bookmarklet here: http://jsbin.com/UdaK/1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() | |
{ | |
var subscriptionDelete = function(item, feedUrl, successCallback, failedCallback) | |
{ | |
var data = | |
{ | |
feed_url: feedUrl, | |
_xsrf: $('[name="_xsrf"]').val(), | |
traditional: true | |
}; | |
$.ajax( | |
{ | |
url: 'http://digg.com/api/subscription/delete.json', | |
method: 'post', | |
data: data, | |
dataType: 'json', | |
success: function(data) | |
{ | |
if (data.status == 'ok') | |
{ | |
successCallback(); | |
} | |
else | |
{ | |
failedCallback(); | |
} | |
}, | |
error: function() | |
{ | |
failedCallback(); | |
} | |
}); | |
}; | |
$('head').append('<style>\ | |
.injected-delete-feed-button {\ | |
display: inline-block;\ | |
float: right;\ | |
min-width: 20px;\ | |
height: 20px;\ | |
margin-right: 10px;\ | |
border-radius: 10px;\ | |
font-size: 18px;\ | |
text-align: center;\ | |
}\ | |
.injected-delete-feed-button:hover {\ | |
color: red;\ | |
}\ | |
</style>'); | |
$('#dr-subscription-list li.dr-feed-list-item[data-feed-url]').each(function() | |
{ | |
var item = $(this), | |
feedUrl = item.data('feed-url'), | |
deleting = false; | |
$('<span class="injected-delete-feed-button">×</span>').appendTo(item.find('.dr-feed-label')).click(function(event) | |
{ | |
if ( ! deleting) | |
{ | |
deleting = true; | |
var deleteButton = $(this); | |
deleteButton.html('…') | |
subscriptionDelete( | |
item, | |
feedUrl, | |
function() | |
{ | |
item.remove(); | |
}, | |
function() | |
{ | |
deleteButton.html(':('); | |
setTimeout(function() | |
{ | |
deleteButton.html('×'); | |
deleting = false; | |
}, 3000); | |
} | |
); | |
} | |
event.stopPropagation(); | |
}); | |
}); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment