// ==UserScript==
// @name NADAmobile Automator
// @description Automate watching NADA and related sites
// @author free21
// @include http://www.nadamobile.com/watch
// @include http://www.nadamovietrailers.com/watch/
// @include http://www.fameapp.io/*
// @include https://www.nadamobile.com/profile
// @grant GM_getValue
// @grant GM_setValue
// @version 1.1.6
// @require http://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
// @namespace https://greasyfork.org/users/57063
// ==/UserScript==
$(document).on('click', ".next-button a", function() {
var form = $("<form></form>");
form.attr({
id: "formid",
action: $(this).attr("href"),
method: "GET",
});
$("body").append(form);
$("#formid").submit();
$("#formid").remove();
return false;
});
$(document).on('click', "#randarticle_0 > h2:nth-child(1) > a", function() {
var form = $("<form></form>");
form.attr({
id: "formid",
action: $(this).attr("href"),
method: "GET",
});
$("body").append(form);
$("#formid").submit();
$("#formid").remove();
return false;
});
$(document).on('click', "#votenow", function() {
var form = $("<form></form>");
form.attr({
id: "formid",
action: $(this).attr("href"),
method: "GET",
});
$("body").append(form);
$("#formid").submit();
$("#formid").remove();
return false;
});
function getRandomArbitrary(min, max) {
return Math.random() * (max - min) + min;
}
window.addEventListener('load', function() {
var diffSites = GM_getValue('diffSites', 'yes');
var randomSite = ['http://www.nadamobile.com/watch','http://www.fameapp.io/2016/07/speed-makeup-challenge-nikki/','http://www.nadamovietrailers.com/watch'][Math.floor(Math.random() * 3)];
var timeto = getRandomArbitrary(1000, 10000);
//for nadamobile.com
if (document.location.href.indexOf('nadamobile.com/watch') > -1) {
setTimeout(function() {
if ($('#new--player video')[0].paused === true) {
$('#new--player video')[0].play();
}
}, 3000);
}
$('.player--hold video').bind('timeupdate', function() {
if (this.currentTime > 1.5 && this.currentTime < 2) {
console.log('time is long enough');
this.currentTime = this.duration - 0.5;
}
});
$('.player--hold video').bind('ended', function() {
if ($('.after-video').is(":visible") === true) {
setTimeout(function() {
$('.next-button a').click();
}, timeto);
}
});
if (diffSites == 'yes') {
$(".ads--player").on('DOMSubtreeModified', function() {
if ($(".ads--player a").attr("href") == '//nadapoints.com') {
setTimeout(function() {
window.location = randomSite;
}, 500);
}
});
}
//for fameapp.io
$('#post-content video').bind('timeupdate', function() {
if (this.currentTime > 1.5 && this.currentTime < 2) {
console.log('time is long enough');
this.currentTime = this.duration - 2;
}
});
$('#post-content video').bind('canplay', function() {
this.play();
});
//sometimes it loads slow, so just using a second method to catch it
if ($('#post-content video')[0] !== undefined) {
if ($('#post-content video')[0].readyState > 0) {
$('#post-content video')[0].play();
}
}
$('#post-content video').bind('ended', function() {
setTimeout(function() {
$("#randarticle_0 > h2:nth-child(1) > a").click();
}, timeto);
});
if (diffSites == 'yes') {
$("#loader").on('DOMSubtreeModified', function() {
if ($("#loader div").css('color') !== undefined) {
setTimeout(function() {
window.location = randomSite;
}, 500);
}
});
}
//for nadamovietrailers.com/watch
$('.jumbotron video').bind('canplay', function() {
this.play();
});
$('.jumbotron video').bind('timeupdate', function() {
if (this.currentTime > 1.5 && this.currentTime < 2) {
console.log('time is long enough');
this.currentTime = this.duration - 2;
}
});
$('.jumbotron video').bind('ended', function() {
setTimeout(function() {
$("#votenow").click();
}, timeto);
});
if (diffSites == 'yes') {
$("#loader").on('DOMSubtreeModified', function() {
if ($("#loader div").css('color') !== undefined) {
setTimeout(function() {
window.location = randomSite;
}, 500);
}
});
}
//sometimes run into this server error, so i just wait and reload to break out of it
if ($('title')[0].text == "Application Error") {
setTimeout(function() {
location.reload();
}, 10000);
}
//in case things go really sideways, just force a reload if it has been too long without anything
setTimeout(function() {
location.reload();
}, 300000);
//setup the settings panel
if (document.location == 'https://www.nadamobile.com/profile') {
$('<div id="autom8">Loading...</div>').insertBefore(
'.referrals');
$('#autom8').css('background-color', '#d83a3d');
$('#autom8').css('font-size', '1.4em');
$('#autom8').css('width', '450px');
$('#autom8').css('padding', '15px');
$('#autom8').css('margin-left', 'auto');
$('#autom8').css('color', 'white');
$('#autom8').css('margin-right', 'auto');
$('#autom8').html(
'<h3>autom8 settings:</h3><br /><input type="checkbox" id="diffsites"> Navigate between different sites. <br/> <span style="font-size:0.8em">If it shows the "no ads available" message, the script will move on to another site to keep trying</span>'
);
if (diffSites == 'yes') {
$("#diffsites").prop('checked', true);
}
$("#diffsites").change(function() {
if (this.checked) {
GM_setValue('diffSites', 'yes');
console.log("set value!");
} else {
GM_setValue('diffSites', 'no');
}
});
}
}, false);