Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name i_filter
- // @namespace i_filter
- // @description Фильтр анкет для сайта intimcity.nl
- // @include https://www.intimcity.nl/*
- // @version 1.01
- // @grant none
- // @author Eumenes
- // @license GNU GPL v3
- // ==/UserScript==
- // Пытаемся загрузить состояние из localStorage
- var i_blacklist = [];
- i_blacklist = localStorage.i_blacklist ? JSON.parse(localStorage.i_blacklist) : [];
- var FSideBar = false;
- // функция для очистки BlackList
- function removeall(){
- i_blacklist = [];
- localStorage.i_blacklist = JSON.stringify(i_blacklist);
- window.location.reload();
- }
- // функция для сохранения BlackList
- function show_blacklist(){
- prompt("BlackList", JSON.stringify(i_blacklist));
- }
- // функция для внесения анкет в BlackList
- function enter_by_id(){
- var new_JSON_black_list = prompt("Enter BlackList");
- var new_removelist = [];
- try {
- new_removelist = JSON.parse(new_JSON_black_list);
- for (var i = 0; i < new_removelist.length; i++) {
- if (i_blacklist.indexOf(new_removelist[i]) == -1) {
- i_blacklist[i_blacklist.length] = new_removelist[i];
- }
- }
- localStorage.i_blacklist = JSON.stringify(i_blacklist);
- window.location.reload();
- }
- catch (e) {
- }
- }
- // функция для исключения анкет из BlackList
- function remove_by_id(){
- var new_JSON_black_list = prompt("Enter WhiteList");
- var new_removelist = [];
- try {
- new_removelist = JSON.parse(new_JSON_black_list);
- for (var i = 0; i < new_removelist.length; i++) {
- var idx = i_blacklist.indexOf(new_removelist[i]);
- if (idx !== -1) {
- i_blacklist.splice(idx, 1);
- }
- }
- localStorage.i_blacklist = JSON.stringify(i_blacklist);
- window.location.reload();
- }
- catch (e) {
- }
- }
- // скрыть/показать боковую панель
- function displaybar()
- {
- var myprofile = document.querySelector('.myprofile');
- if (myprofile.style.display == "block") {
- myprofile.style.display = "none";
- } else {
- myprofile.style.display = "block";
- }
- FSideBar = !FSideBar;
- }
- // функция для работы с BlackList
- function removethis(el){
- var girlid;
- girlid = parseInt(this.previousSibling.firstChild.firstChild.className.substr(8));
- i_blacklist[i_blacklist.length] = girlid;
- localStorage.i_blacklist = JSON.stringify(i_blacklist);
- this.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove();
- }
- 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>');
- 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>');
- document.querySelector('body').insertAdjacentHTML('beforeend', '<div class="myprofile"></div><mybar>></mybar>');
- // Добавляем сбоку выдвижную панель с кнопками
- var title = document.querySelector('mybar');
- title.onclick = displaybar;
- var myprof = document.querySelector('.myprofile');
- var btnCSS = 'margin:5px 32px; text-align: center; width: 160px; font-size:14px;';
- var btnText = ["save blacklist", "load blacklist", "load whitelist", "clear blacklist"];
- var btnFunc = {
- Functions: [show_blacklist, enter_by_id, remove_by_id, removeall]
- }
- for (var i = 0; i < btnText.length; i++) {
- var btn = document.createElement("BUTTON");
- var t = document.createTextNode(btnText[i]);
- btn.appendChild(t);
- btn.style.cssText = btnCSS;
- btn.onclick = btnFunc.Functions[i];
- myprof.appendChild(btn);
- }
- // Пробегаем по всем анкетам
- var titlelist = document.querySelectorAll('.showTip');
- [].forEach.call(titlelist, function(el) {
- // Если анкета находится в BlackList, то удаляем её
- // Иначе добавляем в правый верхний угол кнопку 'Удалить'
- var girlid = parseInt(el.className.substr(8));
- if (i_blacklist.indexOf(girlid) !== -1) {
- el.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.remove();
- } else {
- var remthis = document.createElement('div');
- remthis.textContent = '[X]';
- remthis.onclick = removethis;
- remthis.className = "remthis";
- el.parentNode.parentNode.parentNode.insertBefore(remthis, el.children[0]);
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement