// ==UserScript== // @name dA_FilterNotifications // @namespace http://tampermonkey.net/ // @version 0.5 // @description filter notifications by type // @author Dediggefedde // @match https://www.deviantart.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=deviantart.com // @grant GM.addStyle // @grant GM.getValue // @grant GM.setValue // @downloadURL none // ==/UserScript== //@ts-check /** Adds a bar on deviantart /notification page and sidebar The bar provides buttons to filter and search within displayed elements TODO: trigger fill if filter reduces elements */ (function() { "use strict"; GM.addStyle(` #dA_FN_bar{display:flex;position: sticky;top: 0;z-index: 1;background-color: var(--g-bg-primary);} #dA_FN_bar>div{cursor:pointer;user-select:none} #dA_FN_bar>div:hover{filter: brightness(120%) saturate(150%) invert(20%);} #dA_FN_filterText{height: 1.2em;} .da_FN_selected{border:1px solid red;} .dA_FN_hidden{display:none;} .dA_FN_markHidden .dA_FN_hidden{display:block;} .dA_FN_markHidden .dA_FN_hidden button{ background-image:repeating-linear-gradient(45deg, #ffffff3b 0%, white 2%, #fdfdfd3b 2%,#c1c1c100 4%, white 4%);} .dA_FN_filtered{display:none;} #dA_FN_HideSel[active='2'] ellipse { fill: lightgray;}/*2: hiding=grey*/ #dA_FN_HideSel[active='2'] ellipse[role='iris'] { fill: lightgray;stroke:lightgray}/*2: hiding=grey*/ #dA_FN_HideSel[active='0'] ellipse[role='iris'] { fill: lightgray;stroke:red} /*0: hide selected=red*/ .da_fN_notSelect{user-select:none!important} `); //const itemClasses = ["_375AY", "_2TKoM", "_3PCaz", "_2VY4V"]; //possible classes for notification list item div const itemClassXPath = "//section//div[@data-bucket]/parent::div"; let itemClass = "_375AY"; const filterInterval = 200; //ms let filterTimer; /**@type {HTMLElement} */ let cont = null; //container of items let selRec = { left: 0, top: 0, width: 0, height: 0 }; //div element of selection rectangle let selAnc = { x: 0, y: 0 }; //initial point where you started selecting let dragSel = false; //selection rectangle visible //button images const commBtnSvg = ''; const llamaBtnSvg = ''; const devBtnSvg = ''; const hideBtn = ' ' const fm = { show: 0, hide: 1, only: 2 }; //filter mode //"011-1h16zm-1 2H5v14h14V5zm-4" part of SVG in Journal icon //"01.68-.182l.862.505c.2" part of SVG in Shout icon const ftext = { //text used as regexp for each filter yourComment: ".*Your comment.*", yourLlama: ".*(Your (Llama badges|transactions|mentions|watchers))|(011-1h16zm-1 2H5v14h14V5zm-4)|(01.68-.182l.862.505c.2).*", yourDevs: "