Advertisement
maLakai

Hideable Ads @ sg.hu

Dec 15th, 2012
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var hideableAds = (function() {
  2.     var adBlocks = $('a[href*="ads."]').closest('table');
  3.     var hideAds = function() {
  4.         adBlocks.hide();
  5.         localStorage.setItem('hideableAdsHide', true);
  6.     };
  7.     var beHideable = function() {
  8.         var hideButton = $('<div class="hideAd">&#x2717;</div>');
  9.         hideButton.css({
  10.             position: 'absolute',
  11.             top: '0',
  12.             right: '-20px',
  13.             width: '20px',
  14.             lineHeight: '20px',
  15.             fontSize: '16px',
  16.             textAlign: 'center',
  17.             background: 'red',
  18.             color: 'white',
  19.             cursor: 'pointer',
  20.             zIndex: 1000
  21.         }).click(function(e) {
  22.             e.preventDefault();
  23.             hideAds();
  24.         });
  25.         adBlocks.each(function() {
  26.             var $this = $(this);
  27.             $this.css({
  28.                 position: 'relative'
  29.             });
  30.             $this.append(hideButton);
  31.         });
  32.     };
  33.    
  34.     return {
  35.         init: function() {
  36.             if ( localStorage.getItem('hideableAdsHide') === null ) {
  37.                 beHideable();
  38.             } else {
  39.                 this.hide();
  40.             }
  41.         },
  42.         hide: function() {
  43.             hideAds();
  44.         }
  45.     };
  46. }());
  47.  
  48. hideableAds.init();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement