Greasy Fork

Shined up real nice.

Men's Health Fixer

Removes ad leftovers on Men's Health's websites. Best used with uBlock Origin.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// ==UserScript==
// @name         Men's Health Fixer
// @namespace    http://skoshy.com
// @version      0.4
// @description  Removes ad leftovers on Men's Health's websites. Best used with uBlock Origin.
// @author       Stefan Koshy
// @match        http*://*.menshealth.com/*
// @grant        none
// ==/UserScript==
/* jshint -W097 */
'use strict';

var id = 'mensHealthFixer';

var cleanupCSS = `
  #header.leader, #header.scrolling {
    top: 0 !important;
  }

  .pinit-btn-container {
    display: none !important;
  }
  
  .pinit:hover img {
    opacity: 1 !important;
  }

  .right_rail {
    display: none !important;
  }

  .article-section, .slideshow-section {
    width: 100% !important;
  }

  /* Fix huge images in articles with full-width */
  .slideshow .bx-wrapper img {
    width: auto !important;
    margin: 0 auto;
    max-width: 100%;
    max-height: 500px;
  }
`;

addGlobalStyle(cleanupCSS, id+"CleanupCSS");

// Fixes slideshows so that the ad doesn't show and it automatically goes to the next slide

(function() {
    var nextSlideFromAdButton = document.querySelector('.ad-prev');
    nextSlideFromAdButton.href = 'javascript:';

    setInterval(function() {
        eventFire(nextSlideFromAdButton, 'click');
    }, 1000);
})();




// *****************
// Utility Functions
// *****************

function addGlobalStyle(css, cssID) {
    var head, style;
    head = document.getElementsByTagName('head')[0];
    if (!head) { return; }
    style = document.createElement('style');
    style.id = cssID;
    style.type = 'text/css';
    style.innerHTML = css;
    head.appendChild(style);
}

// Used from http://stackoverflow.com/questions/2705583/simulate-click-javascript
function eventFire(el, etype){
    if (el.fireEvent) {
        (el.fireEvent('on' + etype));
    } else {
        var evObj = document.createEvent('Events');
        evObj.initEvent(etype, true, false);
        el.dispatchEvent(evObj);
    }
}