NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript==
// @name JVFic
// @author ImThatGuy
// @description Vous permet de récupérer que les posts de l'auteur sur un topic
// @include http://www.jeuxvideo.com/*
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
// @require https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.js
// @grant GM_addStyle
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_xmlhttpRequest
// @version 0.1
// @icon http://i.imgur.com/YsCmxgJ.png
// @copyright 2017+, ImThatGuy
// ==/UserScript==
/*
JVFic. 2017.
Codé par ImThatGuy.
2017+, ImThatGuy.
Plugin pour JVCpremium : https://openuserjs.org/scripts/ImThatGuy/JVCpremium
JVFic vous permet d'afficher que les posts de l'auteur sur un topic (très utile pour lic les fic rapidement)
Plugin utilisable sans JVCpremium.
*/
(function() {
'use strict';
var version = "0.1";
var op;
var JVCpremiumPlugin;
if (document.getElementById("PREMIUM") !== null) {
JVCpremiumPlugin = true;
} else {
JVCpremiumPlugin = false;
}
$('head').append('<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/1.1.3/sweetalert.min.css"/>');
GM_addStyle('.jvfic-btn { width:100%;outline:none;margin-bottom: 15px;padding: 0 40px;height:45px;border-radius:2px;text-align: center;text-decoration: none;display: inline-block;font-size: 15px;-webkit-transition-duration: 0.3s; transition-duration: 0.3s;cursor: pointer;background-color: white;color: black;border: 2px solid #e7e7e7; }');
GM_addStyle('.jvfic-btn:hover { background-color: #e7e7e7; }');
$('<button class="jvfic-btn">JvFic</button>').insertAfter( $('.panel-jv-forum').first() );
function listeSujet() {
if (document.getElementsByName('search_in_forum').length === 0) {
return false;
} else {return true;}
}
function nbPosts(b) {
return $(b).find('.bloc-message-forum').size();
}
function removePosts(a, data) {
$(data).find('.bloc-message-forum').each(function() {
if ( $(this).find('.bloc-pseudo-msg').text().trim() != a ) {
$(this).remove();
} else {
$(this).find('.bloc-pseudo-msg').css('color', 'red');
}
});
}
function logConsole(text) {
$('#consolePremium').append('<p style="margin:10px;">'+text+'</p>');
}
if ( JVCpremiumPlugin ) {
logConsole('[INFO] Plugin JVFic '+version+' chargé.');
$('#plugin').append('<img width="70" height="70" src="http://i.imgur.com/YsCmxgJ.png"> <h5>Vous utilisez JVFic '+version+'.</h5><hr>');
$('#non-installer').remove();
}
$('.jvfic-btn').first().click(function() {
if ( listeSujet() ) {
//alert("Vous n'êtes pas sur un topic.");
swal('JvFic', "Erreur, vous n'êtes pas sur un topic.", 'error');
} else {
if ( $('.page-active').first().text() > 1 ) {
var url = '';
var v = window.location.href.split('-');
for (var i=0; i<v.length;i++)
{
if (i==3) {
url += '1'+'-';
} else if (i == v.length-1) {
url += v[i];
} else {
url += v[i]+'-';
}
}
GM_xmlhttpRequest({
method: "GET",
url: url,
onload: function(response) {
op = $(response.responseText).find('.bloc-pseudo-msg').first().text().trim();
logConsole('[JVFic] Auteur du topic : ' + op);
removePosts(op, document);
if ( nbPosts(document) < 1) {
$("<p>L'auteur n'a pas posté sur cette page.</p>").insertAfter( $('.bloc-pagi-default').first() );
}
}
});
} else {
op = $('.bloc-pseudo-msg').first().text().trim();
logConsole('[JVFic] Auteur du topic : ' + op);
removePosts(op, document);
}
}
});
})();