Greasy Fork is available in English.

Unsplash Remove Ads

Unsplash Ads

  1. // ==UserScript==
  2. // @name Unsplash Remove Ads
  3. // @namespace https://www.iplaysoft.com
  4. // @description Unsplash Ads
  5. // @version 0.33
  6. // @author X
  7. // @match https://unsplash.com/*
  8. // @require https://cdn.staticfile.org/jquery/3.6.1/jquery.min.js
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=unsplash.com
  10. // @grant GM_addStyle
  11. // ==/UserScript==
  12.  
  13. /* globals $ */
  14.  
  15. function removeAdsBlock(){
  16. $($("div[data-test*='AffiliatesGrid-Content']").get(0)).parent().hide();
  17. //$($("div[data-test*='AffiliatesGrid-Content']").get(0)).parent().parent().hide();
  18. }
  19.  
  20. function removeAdsInsideList(targetDiv){
  21.  
  22. removeAdsBlock();
  23.  
  24. if(targetDiv.nodeName=="DIV" ||targetDiv.nodeName=="div"){
  25. var fig=$(targetDiv).find("figure[itemprop*='image']");
  26.  
  27. if(fig.length>0){
  28. //console.log($(fig).find("a:contains('Unlock')").length);
  29.  
  30. //console.log(fig[i]);
  31. //var ads=$(fig.get()).find("div:contains('Unsplash+')");
  32. var ads=$(fig.get()).find("a:contains('Unlock')");
  33. if(ads.length>0){
  34. // console.log(ads);
  35. $(ads.get()).parentsUntil("figure").hide();
  36. //console.log(ads.get());
  37. }
  38. //}
  39. //console.log($(fig).find("a"));
  40. //var ads=$(fig).find("img");
  41. //var ads=$(fig.get()).find("div:textEquals('Unsplash+')")
  42. //var ads=$(fig.get()).find("div:textEquals('Unsplash\+')")
  43. //if(ads.length>0){
  44. // console.log(ads);
  45. //}
  46. }
  47.  
  48. var data_ad=$(targetDiv).find("div[data-ad*='true']");
  49. if(data_ad.length>0){
  50. $(data_ad.get()).hide()
  51. //console.log(data_ad.get());
  52. }
  53. }
  54. }
  55.  
  56. function scrollRemoveAds(){
  57. var targetDiv=$("div[data-test*='masonry-grid-count-three']").parent().get(0);
  58. removeAdsInsideList(targetDiv);
  59. }
  60.  
  61.  
  62. (function() {
  63. 'use strict';
  64. $(document).ready(function(){
  65.  
  66. removeAdsBlock();
  67.  
  68. $("div[data-test*='masonry-grid-count-three']").parent().on('DOMSubtreeModified', function(e) {
  69. removeAdsInsideList(e.target);
  70. });
  71.  
  72. $(window).scroll(function(){
  73. scrollRemoveAds();
  74. });
  75.  
  76. });
  77. })();