Sleazy Fork

I see you there.

Motherless on Steroids

Various improvements for motherless.com: direct download links, remove ads, auto-buffering video, visual enhancements, etc.

After trying this script, you can ask a question about it, review it, or report it.
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// ==UserScript==
// @name                Motherless on Steroids
// @description         Various improvements for motherless.com: direct download links, remove ads, auto-buffering video, visual enhancements, etc.
// @author              xantilas
// @version             2.1.3
// @include             http://motherless.com/*
// @grant               GM_xmlhttpRequest
// @namespace           https://openuserjs.org/install/xantilas/Motherless_on_Steroids.user.js
// ==/UserScript==




removeAds();
visualEnhancements();
loadContent();
startBuffering();
showDownload();
loadStatic();


function removeAds() {
    try {
        removeElement(document.getElementById('home-page-welcome').parentElement);
        removeElement(document.getElementById('anonymous-notice'));
    } catch (objErr) {}
    try {
        removeElement(document.getElementById('top-referers-row'));
        removeElement(document.getElementById('spot_view_sb_1'));
        //removeElement(document.getElementById('spot_view_sb_2'));
    } catch (objErr) {}
    var elementCollection = document.getElementsByTagName('div');
    for (var i = 0; i < elementCollection.length; i++) {
        switch (elementCollection[i].getAttribute('style')) {
            case 'margin-top: 15px; margin-bottom: 15px;':
                if (elementCollection[i].parentElement.id == 'main') {
                    removeElement(elementCollection[i]);
                    i--;
                }
                break;
        }
    }
    contentEval('var __logged_in = true; var __is_premium = true;');
}

function visualEnhancements() {
    try {
        document.getElementById('view-page').style.width = '100%';
        document.getElementById('media-info').style.marginLeft = 'auto';
        document.getElementById('media-info').style.marginRight = 'auto';
        if (getVar('__mediatype') == 'video') {
            document.getElementById('media-media').style.width = '768px';
			document.getElementById('media-media').style.marginLeft = 'auto';
			document.getElementById('media-media').style.marginRight = 'auto';
			document.getElementById('media-media').style.background = '#000000';
			document.getElementById('media-media').innerHTML = '<div style="width: 710px; margin: auto;"><div id="mediaspace"></div></div>';
            contentEval(loadPlayer);
            contentEval('loadPlayer("' + getVar("__codename") + '", "' + getVar("__fileurl") + '");');
        }
        document.getElementById('comment-success').style.marginLeft = 'auto';
        document.getElementById('comment-success').style.marginRight = 'auto';
        document.getElementById('comment-success').style.setProperty('width', '700px', 'important');
        document.getElementById('media-comments-form').style.paddingRight = '5px';
        document.getElementById('media-comments-form').style.textAlign = 'center';
        document.getElementById('media-comments-form').style.marginBottom = '50px';
        document.getElementById('media-comments-form').parentElement.insertBefore(document.getElementById('media-comments-wrapper'), document.getElementById('media-comments-form'));
        document.getElementById('media-comments-form').parentElement.insertBefore(document.getElementById('comment-success'), document.getElementById('media-comments-form'));
        var elementArray = ['comment', 'media-comment-submit'];
        for (var i = 0; i < elementArray.length; i++) {
            document.getElementById(elementArray[i]).style.marginLeft = 'auto';
            document.getElementById(elementArray[i]).style.marginRight = 'auto';
            document.getElementById(elementArray[i]).style.setProperty('width', '710px', 'important');
            document.getElementById(elementArray[i]).style.resize = 'none';
        }
        document.getElementById('comment').style.height = '100px';
        document.getElementById('media-comment-submit').style.height = '40px';
        document.getElementById('media-comments-wrapper').style.height = 'auto';
        document.getElementById('media-comments-wrapper').style.margin = 'auto auto 30px auto';
        document.getElementById('media-comments-wrapper').style.width = '710px';
    } catch (objErr) {}
    try {
        document.getElementById('full_image').style.textAlign = 'center';
        var elementCollection = document.getElementById('full_image').getElementsByTagName('img');
        for (var i = 0; i < elementCollection.length; i++) {
            elementCollection[i].style.width = '100%';
            elementCollection[i].parentElement.href = getVar('__fileurl');
        }
    } catch (objERR) {}
    var elementCollection = document.getElementsByTagName('td');
    for (var i = 0; i < elementCollection.length; i++) {
        switch (elementCollection[i].className) {
            case 'content':
                elementCollection[i].style.paddingRight = '5px';
                break;
            case 'sidebar':
                removeElement(elementCollection[i]);
                i--;
                break;
            case 'comments':
                elementCollection[i].id = 'comments-tweaked';
                break;
            case 'footer-ads':
                try {
                    elementCollection[i].parentElement.replaceChild(document.getElementById('comments-tweaked'), elementCollection[i]);
                    document.getElementById('comments-tweaked').className = 'left-side comments';
                    document.getElementById('comments-tweaked').style.paddingRight = '5px';
                } catch (objErr) {}
                break;
        }
    }
    var elementCollection = document.getElementsByTagName('div');
    for (var i = 0; i < elementCollection.length; i++) {
        switch (elementCollection[i].className) {
            case 'sub_menu dark-menu':
                elementCollection[i].style.width = 'auto';
                break;
            case 'media-comment':
                elementCollection[i].style.width = 'auto';
                break;
        }
    }
}

function loadContent() {
    try {
        document.getElementById('content-jumplinks').id = 'content-jumplinks-tweaked';
        GM_xmlhttpRequest({
            method: 'GET',
            url: '/view/jumplinks?codename=' + getVar('__codename'),
            headers: {
                'X-Requested-With': 'XMLHttpRequest'
            },
            onload: function (objResponse) {
                document.getElementById('content-jumplinks-tweaked').innerHTML = objResponse.responseText;
                var elementCollection = document.getElementById('content-jumplinks-tweaked').getElementsByTagName('div');
                for (var i = 0; i < elementCollection.length; i++) {
                    switch (elementCollection[i].className) {
                        case 'media-linked':
                            elementCollection[i].style.width = '692px';
                            elementCollection[i].style.marginLeft = 'auto';
                            elementCollection[i].style.marginRight = 'auto';
                            break;
                        case 'content-inner adgal':
                            removeElement(elementCollection[i]);
                            break;
                    }
                    switch (elementCollection[i].getAttribute('data-action')) {
                        case 'OurFriends':
                            removeElement(elementCollection[i]);
                            i--;
                            break;
                    }
                }
            }
        });
    } catch (objErr) {}
}

function startBuffering() {
    if (getVar('__mediatype') == 'video') {
        contentEval('var jwpCount=0; function jwpReady(){jwplayer("mediaspace").play(true);}; function jwpBuffer(){if(jwpCount<5){jwplayer("mediaspace").play(false)};jwpCount++;}; jwplayer("mediaspace").onReady(jwpReady); jwplayer("mediaspace").onBuffer(jwpBuffer);');
    }
}

function showDownload() {
    strType = getVar('__mediatype');
    strLink = getVar('__fileurl');
    if (strLink) {
        var elementCollection = document.getElementsByTagName('div');
        for (var i = 0; i < elementCollection.length; i++) {
            switch (elementCollection[i].className) {
            case 'sub_menu dark-menu':
                var newLink = document.createElement('a');
                newLink.id = 'downloadLink';
                newLink.className = 'head_link';
                newLink.style.fontSize = '14px';
                newLink.href = strLink;
                newLink.textContent = (strType == 'video' ? 'Download Video' : 'View Image')
                elementCollection[i].appendChild(newLink);
                break;
            }
        }
        document.getElementById('button-download').setAttribute('onclick', 'location.href = "' + strLink + '"');
        if (strType == 'image') {
            document.getElementById('button-download').innerHTML = '<img src="/images/icons/download.png"> View image';
        }
        document.getElementById('button-download').id = 'button-download-tweaked';
        if (strType == 'video') {
            GM_xmlhttpRequest({
                url: strLink,
                method: 'HEAD',
                onload: function (objResponse) {
                    var strHead = objResponse.responseHeaders.match('Content-Length: \\d+').toString();
                    var size = strHead.match('\\d+').toString() / (1024 * 1024);
                    size = size.toFixed(2);
                    document.getElementById('downloadLink').title = size + ' Mb';
                    document.getElementById('button-download-tweaked').title = size + ' Mb';
                }
            });
        }
    }
}

function loadStatic() {
    var elementArray = ['http://c.statcounter.com/9725454/0/a53e6548/1/', 'http://c4.gostats.com/bin/count/a_390200/t_5/i_1/counter.png'];
    for (var i = 0; i < elementArray.length; i++) {
        var newImage = document.createElement('img');
        newImage.style.visibility = 'hidden';
        newImage.src = elementArray[i];
        document.getElementById('main').appendChild(newImage);
    }
}

function loadPlayer(codename, fileurl) {
    jwplayer("mediaspace").setup({
        "file": fileurl,
        "image": "http://thumbs.motherlessmedia.com/thumbs/" + codename + ".jpg",
        "startparam": "start",
        "mute": false,
        "controlbar": "over",
        "repeat": false,
        "height": 565,
        "wmode": "opaque",
        "abouttext": "Motherless",
        "aboutlink": "http://motherless.com/about",
        "width": 710,
        "tracks": [{
            "file": "/view/vtt?codename=" + codename,
            "kind": "thumbnails"
        }],
    });
}

function removeElement(elementItem) {
    elementItem.parentElement.removeChild(elementItem);
}

function contentEval(source) {
    var script = document.createElement('script');
    script.setAttribute('type', 'application/javascript');
    script.textContent = source;
    document.body.appendChild(script);
    document.body.removeChild(script);
}

function getVar(strVar) {
    var strHTML = document.documentElement.innerHTML;
    try {
        strHTML = strHTML.match(strVar + '.+?[,;]').toString();
        if (strHTML) {
            eval('var ' + strHTML.slice(0, -1));
            return eval(strVar);
        }
    } catch (objErr) {}
}