A LILiK chrome extension for the well known 9gag website
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.1 KiB

9 years ago
  1. var currentVideo = null;
  2. jQuery("#list-view-2").on( "click", ".badge-evt.post-read-more", function( event ) {
  3. actual = jQuery(event.target);
  4. actual.parent().find("img").attr("src", actual.attr('href').replace("/gag/", "http://img-9gag-fun.9cache.com/photo/") + "_700b_v1.jpg");
  5. actual.remove();
  6. event.preventDefault();
  7. });
  8. jQuery( document ).ready(function() {
  9. jQuery("#overlay-container").remove();
  10. });
  11. $("#list-view-2").on('contextmenu', "video", function(e) {
  12. currentVideo = jQuery(event.target);
  13. });
  14. function downloadURI(uri, name)
  15. {
  16. var link = document.createElement("a");
  17. link.download = "dsfsd";
  18. link.href = uri;
  19. link.click();
  20. }
  21. chrome.extension.onMessage.addListener(
  22. function(request, sender, sendResponse) {
  23. if (request.command == "copyGifUrl" || request.command == "downloadGif"){
  24. url = currentVideo.parent().data("image").replace("a.gif", ".gif")
  25. }
  26. if (request.command == "copyGifUrl"){
  27. sendResponse({url: url});
  28. }else if (request.command == "downloadGif"){
  29. console.log(currentVideo.parents("article").find("h2").text().trim());
  30. downloadURI(url, currentVideo.parents("article").find("h2").text().trim() + ".gif");
  31. }
  32. }
  33. );