Advertisement
Guest User

Untitled

a guest
Aug 6th, 2017
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Chouaddon
  3. // @namespace   choualbox.com
  4. // @description Addon qui améliore la navigation sur Choualbox
  5. // @author      Appineos - http://choualbox.com/blog/appineos (Benji)
  6. // @editor      CatShadow - http://choualbox.com/blog/catshadow
  7. // @include     http://choualbox.com/*
  8. // @include     https://choualbox.com/*
  9. // @exclude     http://choualbox.com/blog/*
  10. // @exclude     https://choualbox.com/blog/*
  11. // @version     4.1.1
  12. // @grant       GM_getValue
  13. // @grant       GM_setValue
  14. // @grant       GM_log
  15. // @require     http://code.jquery.com/jquery-2.0.3.min.js
  16. // @updateURL   https://github.com/BenjiCB/Chouaddon/raw/master/Chouaddon.user.js
  17. // @downloadURL https://github.com/BenjiCB/Chouaddon/raw/master/Chouaddon.user.js
  18. // ==/UserScript==
  19.  
  20. regPseudo = /blog\/(.*)/;
  21. mediaBox = [];
  22. regSeries = /([^\t]+?)\.*#[0-9]+.*$/;
  23.  
  24. try {
  25.     if (GM_getValue.toString().indexOf("not supported") != -1) {
  26.         this.GM_getValue=function (key,def) {
  27.             return localStorage[key] || def;
  28.         };
  29.         this.GM_setValue=function (key,value) {
  30.             localStorage[key]=value;
  31.         };
  32.         this.GM_deleteValue=function (key) {
  33.             return delete localStorage[key];
  34.         };
  35.     }
  36. }
  37. catch (e) {
  38.     console.log(e);
  39. }
  40. this.GM_getBoolValue = function (key, def) {
  41.     return (this.GM_getValue(key, def) === true || this.GM_getValue(key, def) == "true");
  42. };
  43.  
  44. function boucle() {
  45.     boxs = document.getElementsByClassName('box_itemboucle');
  46.  
  47.     for (var i in boxs) {
  48.         if (isNaN(i)) continue;
  49.         if (boxs[i].classList.contains('dejaTraitee')) continue;
  50.         box = boxs[i];
  51.         //droiteBox = box.getElementsByClassName('droite')[0];
  52.         //mediaBox = droiteBox.getElementsByClassName('medias')[0];
  53.         //idUnique = box.getElementsByClassName('nbcoms')[0].pathname;
  54.         box.classList.add('dejaTraitee');
  55.         titre = box.getElementsByTagName("h3")[0].getElementsByTagName("a")[0].innerHTML;
  56.  
  57.         if (box.classList.contains('mb3'))
  58.          pseudoId = box.getElementsByClassName('b--near-white')[0].getElementsByTagName('a')[0].innerText;
  59.         else
  60.          pseudoId = box.getElementsByClassName('fs12')[0].getElementsByTagName('a')[0].innerText;
  61.  
  62.         if ((ignoreList.indexOf(pseudoId) == -1)) { //Si la personne n'est pas ignorée
  63.             if (!(
  64.                 (box.getElementsByClassName('boutonsvote')[0].getElementsByClassName('voted').length != 0)
  65.                 && (
  66.                     (GM_getBoolValue('redAutoVote', false)
  67.                      || GM_getBoolValue('delAutoVote', false)
  68.                     )
  69.                 )
  70.             )) {
  71.                 if (GM_getBoolValue('affLienIgnore', false)) {
  72.                     lienIgnore = document.createElement('a');
  73.                     lienIgnore.innerHTML = '<span class="glyphicon glyphicon-eye-close"></span> Ignorer ' + pseudoId;
  74.                     lienIgnore.className = 'ignoreNickname-' + pseudoId;
  75.                     lienIgnore.style.cursor = "pointer";
  76.                     lienIgnore.onclick = function () { ajoutIgnoreList(this); };
  77.                     lienIgnore.style.color = 'rgb(102, 102, 102)';
  78.                     //mediaBox.appendChild(lienIgnore);
  79.                 }
  80.                 if (GM_getBoolValue('series', false) && regSeries.test(titre)) {
  81.                     titreDec = regSeries.exec(titre);
  82.                     lienSerie = document.createElement('a');
  83.                     lienSerie.innerHTML = '<span class="glyphicon glyphicon-search"></span> Série ' + titreDec[1];
  84.                     lienSerie.href = 'http://choualbox.com/recherche?q=' + encodeURIComponent(titreDec[1]);
  85.                     //mediaBox.appendChild(lienSerie);
  86.                 }
  87.             }
  88.             else {
  89.                 if (GM_getBoolValue('delAutoVote', false)) {
  90.                     box.parentNode.removeChild(box);
  91.                 }
  92.                 else {
  93.                     console.log(box);
  94.                     box.style.backgroundColor = '#EFEFEF';
  95.                     box.style.minHeight = 0;
  96.                     //box.innerHTML = '<a style="color: rgb(102, 102, 102)" href="' + idUnique + '">Box déjà votée (' + pseudoId + ') - ' + titre + '</a>';
  97.                 }
  98.              }
  99.         }
  100.         else {
  101.             if (GM_getBoolValue('delIgnBox', false)) {
  102.                 box.parentNode.removeChild(box);
  103.             }
  104.             else {
  105.                 box.style.display = 'none';
  106.                 //box.innerHTML = '<a style="color: rgb(102, 102, 102)" href="' + idUnique + '">Box ignorée (' + pseudoId + ') - ' + titre + '</a>';
  107.             }
  108.         }
  109.     }
  110. }
  111. function afficherImagesCommentaires() {
  112.     medias = document.getElementsByClassName('media_image');
  113.     for (var i in medias) {
  114.         if (isNaN(i)) continue;
  115.         lien = medias[i].getElementsByTagName('a')[0];
  116.         if (lien.getElementsByClassName('gif-overlay').length > 0)
  117.         lien.removeChild(lien.getElementsByClassName('gif-overlay')[0]);
  118.         image = lien.getElementsByTagName('img')[0];
  119.         image.src = lien.href;
  120.         image.style.maxWidth = '100%';
  121.     }
  122. }
  123. function ajoutIgnoreList(obj) {
  124.     id = obj.className;
  125.     regPseudo = /ignoreNickname-(.*)/;
  126.     if ((regPseudo.test(id)) && (pseudo = regPseudo.exec(id)[1]) && (!ignoreList.hasOwnProperty(pseudo)) && (ignoreList.indexOf(pseudo) == -1)) {
  127.             ignoreList = GM_getValue('ignoreList', "").split(", ");
  128.             if ("" == GM_getValue('ignoreList', "")) GM_setValue('ignoreList', pseudo);
  129.             else {
  130.                 ignoreList.push(pseudo);
  131.                 GM_setValue('ignoreList', ignoreList.join(", "));
  132.                 document.getElementById('ignoreList').value = GM_getValue('ignoreList', "");
  133.             }
  134.     }
  135.     obj.innerHTML = "Ignoré";
  136. }
  137. function toggleSidebar(sidebar) {
  138.     if (sidebar != null) {
  139.         if (GM_getBoolValue('rmSidebar', false)) {
  140.             sidebar.style.display = 'none';
  141.             var a = document.getElementById('principal').getElementsByClassName('col-xs-8')[0];
  142.             a.className = 'col-xs-12';
  143.             a.style.backgroundColor = 'white';
  144.         }
  145.         else {
  146.             sidebar.style.display = 'block';
  147.             document.getElementById('principal').getElementsByClassName('col-xs-12')[0].className = 'col-xs-8';
  148.         }
  149.     }
  150. }
  151. function ajouterOptionMenu(label, nomInterne, type, parent, def) {
  152.     option = document.createElement("div");
  153.     option.style.marginBottom = "5px";
  154.     if (type == "textarea") optionInput = document.createElement(type);
  155.     else {
  156.         optionInput = document.createElement("input");
  157.         optionInput.type = type;
  158.     }
  159.     if (type == "checkbox"){
  160.         optionInput.onclick = function () { optionChange(this); };
  161.         optionInput.checked = GM_getBoolValue(nomInterne, def);
  162.     }
  163.     else {
  164.         optionInput.onblur = function () { optionChange(this); };
  165.         optionInput.value = GM_getValue(nomInterne, def);
  166.     }
  167.     optionInput.id = nomInterne;
  168.     optionInput.style.height = "auto";
  169.     optionInput.style.width = "auto";
  170.     optionInput.style.marginRight = "5px";
  171.  
  172.     optionLabel = document.createElement("label");
  173.     optionLabel.htmlFor = nomInterne;
  174.     optionLabel.innerHTML = label;
  175.     optionLabel.style.display = "inline";
  176.     optionLabel.style.fontWeight = "normal";
  177.     if (type == "textarea") {
  178.         option.appendChild(optionLabel);
  179.         option.appendChild(document.createElement('br'));
  180.         optionInput.style.width = "100%";
  181.         option.appendChild(optionInput);
  182.     }
  183.     else {
  184.         option.appendChild(optionInput);
  185.         option.appendChild(optionLabel);
  186.         if (type == "color") {
  187.             optionInput.style.width = "38px";
  188.             optionInput.style.height = "26px";
  189.         }
  190.     }
  191.     parent.appendChild(option);
  192. }
  193.  
  194. function optionChange(optionInput) {
  195.     if (optionInput.type == "checkbox") val = optionInput.checked;
  196.     else val = optionInput.value;
  197.     GM_setValue(optionInput.id, val);
  198. }
  199. gCGW = document.createElement('div');
  200. gCGW.classList.add('dropdown-menu');
  201. gCGW.style.width = "600px";
  202. gCGW.style.padding = "5px";
  203. titregCGW = document.createElement('h1');
  204. titregCGW.innerHTML = "Chouaddon v4.1 - Configuration";
  205. gCGW.appendChild(titregCGW);
  206.  
  207. ajouterOptionMenu('Réduire les box déjà votées (un lien sera quand même affiché)', 'redAutoVote', "checkbox", gCGW, false);
  208. ajouterOptionMenu('Supprimer les box déjà votées', 'delAutoVote', "checkbox", gCGW, false);
  209. ajouterOptionMenu('Images commentaire en taille réelle', 'affichageImagesCommentaires', "checkbox", gCGW, false);
  210. ajouterOptionMenu('Lien auto de recherche lors d\'une série', 'series', "checkbox", gCGW, false);
  211. ajouterOptionMenu('Lien sur chaque box pour ignorer les box de l\'auteur', 'affLienIgnore', "checkbox", gCGW, false);
  212.  
  213. ajouterOptionMenu('Utilisateurs ignorés : (Séparés par des virgules, pas de majuscules)', 'ignoreList', "textarea", gCGW, "");
  214. ajouterOptionMenu('Supprimer les boxs ignorées (Réduites sinon)', 'delIgnBox', "checkbox", gCGW, false);
  215. // Menu de config
  216. elementMenu = document.createElement('li');
  217. elementMenu.className = 'with-icon tooltip-bottom';
  218. elementMenu.attributes.style = "position:relative;";
  219.  
  220. filtreElementMenu = document.createElement('i');
  221. filtreElementMenu.className = 'glyphicon glyphicon-plus';
  222. filtreElementMenu.style.cursor = "pointer";
  223.  
  224. lienElementMenu = document.createElement('a');
  225. lienElementMenu.style.paddingTop = "15px";
  226. lienElementMenu.style.paddingLeft = "0px";
  227. lienElementMenu.style.paddingRight = "0px";
  228. lienElementMenu.style.paddingBottom = "0px";
  229. lienElementMenu.onclick = function() {
  230.     gCGW.style.display = (gCGW.style.display == "none" || gCGW.style.display == "") ? "block" : "none";
  231.     filtreElementMenu.className = (gCGW.style.display == "none" || gCGW.style.display == "") ? 'glyphicon glyphicon-plus' : 'glyphicon glyphicon-minus';
  232. };
  233.  
  234. lienElementMenu.appendChild(filtreElementMenu);
  235. elementMenu.appendChild(lienElementMenu);
  236. elementMenu.appendChild(gCGW);
  237. document.getElementById('coldroite').appendChild(elementMenu);
  238.  
  239. //Sidebar
  240. elementMenu2 = document.createElement('li');
  241. elementMenu2.className = 'with-icon tooltip-bottom';
  242. elementMenu2.attributes.style = "position:relative;";
  243.  
  244. sidebarElementMenu = document.createElement('i');
  245. sidebarElementMenu.className = GM_getBoolValue('rmSidebar', false) ? 'glyphicon glyphicon-align-left' : ' glyphicon glyphicon-indent-right';
  246. sidebarElementMenu.style.cursor = "pointer";
  247.  
  248. lienElementMenu2 = document.createElement('a');
  249. lienElementMenu2.style.paddingTop = "15px";
  250. lienElementMenu2.style.paddingLeft = "0px";
  251. lienElementMenu2.style.paddingRight = "0px";
  252. lienElementMenu2.style.paddingBottom = "0px";
  253. lienElementMenu2.style.marginLeft = '10px';
  254. lienElementMenu2.onclick = function() {
  255.     GM_setValue('rmSidebar', !GM_getBoolValue('rmSidebar', false));
  256.     sidebarElementMenu.className = GM_getBoolValue('rmSidebar', false) ? 'glyphicon glyphicon-align-left' : ' glyphicon glyphicon-indent-right';
  257.  
  258.     if (document.getElementById('sidebar') != null) { toggleSidebar(document.getElementById('sidebar')); }
  259.     if (document.getElementsByClassName('col-xs-4').length > 0) { toggleSidebar(document.getElementsByClassName('col-xs-4')[0]); }
  260. };
  261.  
  262. lienElementMenu2.appendChild(sidebarElementMenu);
  263. elementMenu2.appendChild(lienElementMenu2);
  264.  
  265. document.getElementById('coldroite').appendChild(elementMenu2);
  266.  
  267.  
  268. document.getElementById("ignoreList").style.resize = "vertical";
  269. document.getElementById("ignoreList").style.maxHeight = "400px";
  270.  
  271.  
  272. ignoreList = GM_getValue('ignoreList', "").split(", ");
  273. if (document.getElementsByClassName('box_itemboucle').length > 0) { boucle(); setInterval(boucle, 3000); }
  274. if (document.getElementsByClassName('commentaires').length > 0 && GM_getBoolValue('affichageImagesCommentaires', false)) { afficherImagesCommentaires(); }
  275. if (document.getElementById('sidebar') != null && GM_getBoolValue('rmSidebar', false)) { toggleSidebar(document.getElementById('sidebar')); }
  276. if (document.getElementsByClassName('col-xs-4').length > 0 && GM_getBoolValue('rmSidebar', false)) { toggleSidebar(document.getElementsByClassName('col-xs-4')[0]); }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement