Advertisement
Guest User

i_filter_v1.01.user

a guest
Jul 8th, 2017
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        i_filter
  3. // @namespace   i_filter
  4. // @description Фильтр анкет для сайта intimcity.nl
  5. // @include     https://www.intimcity.nl/*
  6. // @version     1.01
  7. // @grant       none
  8. // @author      Eumenes
  9. // @license     GNU GPL v3
  10. // ==/UserScript==
  11.  
  12. // Пытаемся загрузить состояние из localStorage
  13. var i_blacklist = [];
  14. i_blacklist = localStorage.i_blacklist ? JSON.parse(localStorage.i_blacklist) : [];
  15. var FSideBar = false;
  16.  
  17. // функция для очистки BlackList
  18. function removeall(){
  19.     i_blacklist = [];
  20.     localStorage.i_blacklist = JSON.stringify(i_blacklist);
  21.     window.location.reload();
  22. }
  23.  
  24. // функция для сохранения BlackList
  25. function show_blacklist(){
  26.     prompt("BlackList", JSON.stringify(i_blacklist));
  27. }
  28.  
  29. // функция для внесения анкет в BlackList
  30. function enter_by_id(){
  31.     var new_JSON_black_list = prompt("Enter BlackList");
  32.     var new_removelist = [];
  33.     try {
  34.         new_removelist = JSON.parse(new_JSON_black_list);
  35.         for (var i = 0; i < new_removelist.length; i++) {
  36.             if (i_blacklist.indexOf(new_removelist[i]) == -1) {
  37.                 i_blacklist[i_blacklist.length] = new_removelist[i];
  38.             }
  39.         }
  40.         localStorage.i_blacklist = JSON.stringify(i_blacklist);
  41.         window.location.reload();
  42.     }
  43.     catch (e) {
  44.        
  45.     }
  46. }
  47.  
  48. // функция для исключения анкет из BlackList
  49. function remove_by_id(){
  50.     var new_JSON_black_list = prompt("Enter WhiteList");
  51.     var new_removelist = [];
  52.     try {
  53.         new_removelist = JSON.parse(new_JSON_black_list);
  54.         for (var i = 0; i < new_removelist.length; i++) {
  55.             var idx = i_blacklist.indexOf(new_removelist[i]);
  56.             if (idx !== -1) {
  57.                 i_blacklist.splice(idx, 1);
  58.             }
  59.         }
  60.         localStorage.i_blacklist = JSON.stringify(i_blacklist);
  61.         window.location.reload();
  62.     }
  63.     catch (e) {
  64.        
  65.     }
  66. }
  67.  
  68. // скрыть/показать боковую панель
  69. function displaybar()
  70. {
  71.     var myprofile = document.querySelector('.myprofile');
  72.     if (myprofile.style.display == "block") {
  73.         myprofile.style.display = "none";
  74.     } else {
  75.         myprofile.style.display = "block";
  76.     }
  77.     FSideBar = !FSideBar;
  78. }
  79.  
  80. // функция для работы с BlackList
  81. function removethis(el){
  82.     var girlid;
  83.     girlid = parseInt(this.previousSibling.firstChild.firstChild.className.substr(8));
  84.     i_blacklist[i_blacklist.length] = girlid;
  85.     localStorage.i_blacklist = JSON.stringify(i_blacklist);
  86.     this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove();
  87. }
  88.  
  89. document.querySelector('body').insertAdjacentHTML('beforeend', '<style>.remthis{background-color:#008bec;color:#fff;cursor:pointer;font-size:10px;padding:2px 2px;z-index:999999999;}.remthis{position:absolute;display: block;}.remthis:hover{background-color:#cb4437}</style>');
  90. document.querySelector('body').insertAdjacentHTML('beforeend', '<style>.myprofile {width: 1px;height: 1px;background: #eee;display: none;position:fixed;left:0;top:200px;}mybar {display: block;padding: 4px 8px;background: #666;color: #fff;position:fixed;left:0;top:200px;text-align: center;}</style>');
  91. document.querySelector('body').insertAdjacentHTML('beforeend', '<div class="myprofile"></div><mybar>></mybar>');
  92. // Добавляем сбоку выдвижную панель с кнопками
  93. var title = document.querySelector('mybar');
  94. title.onclick = displaybar;
  95. var myprof = document.querySelector('.myprofile');
  96. var btnCSS = 'margin:5px 32px; text-align:  center; width: 160px; font-size:14px;';
  97. var btnText = ["save blacklist", "load blacklist", "load whitelist", "clear blacklist"];
  98. var btnFunc = {
  99.     Functions: [show_blacklist, enter_by_id, remove_by_id, removeall]  
  100. }
  101. for (var i = 0; i < btnText.length; i++) {
  102.     var btn = document.createElement("BUTTON");
  103.     var t = document.createTextNode(btnText[i]);
  104.     btn.appendChild(t);
  105.     btn.style.cssText = btnCSS;
  106.     btn.onclick = btnFunc.Functions[i];
  107.     myprof.appendChild(btn);
  108. }
  109.  
  110. // Пробегаем по всем анкетам
  111. var titlelist = document.querySelectorAll('.showTip');
  112. [].forEach.call(titlelist, function(el) {
  113.     // Если анкета находится в BlackList, то удаляем её
  114.     // Иначе добавляем в правый верхний угол кнопку 'Удалить'
  115.     var girlid = parseInt(el.className.substr(8));
  116.     if (i_blacklist.indexOf(girlid) !== -1) {
  117.         el.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove();
  118.     } else {
  119.         var remthis = document.createElement('div');
  120.         remthis.textContent = '[X]';
  121.         remthis.onclick = removethis;
  122.         remthis.className = "remthis";
  123.         el.parentNode.parentNode.parentNode.insertBefore(remthis, el.children[0]);
  124.     }
  125. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement