// ==UserScript== // @name dA_FilterNotifications // @namespace http://tampermonkey.net/ // @version 0.9 // @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 https://update.greasyfork.icu/scripts/445528/dA_FilterNotifications.user.js // @updateURL https://update.greasyfork.icu/scripts/445528/dA_FilterNotifications.meta.js // ==/UserScript== //@ts-nocheck /** 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} #dA_FN_settings{width:30vw;position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background-color:#edffea;display:grid;grid-template-columns: 80% auto;grid-template-rows: 3em repeat(5,2em) 7em 2em; grid-gap: 10px;padding: 5px;border-radius: 10px;border: 1px ridge;box-shadow: 2px 2px 10px #777;align-items: center;user-select:none;} #dA_FN_customCSS {grid-column: 1 /span 2;resize:none;height:100%;} #dA_FN_settings .dA_FN_setBtn{grid-column: 1/span 2; text-align: center;} #dA_FN_OKBtn {width: 100px;cursor: pointer;} #dA_FN_settings input[type=checkbox]{cursor: pointer;} #dA_FN_settings label{cursor: pointer;width:100%;} #dA_FN_settings h3{grid-column:1 /span 2;font-weight: bold;text-align: center;font-size: larger;} #dA_FN_cancelBtn{cursor: pointer;position:absolute;top:2px;right:2px;background-color:transparent;border:none;font-size:larger;} #dA_FN_cancelBtn:hover{color: #ccc;} #dA_FN_settingBtn{position: absolute;top: 2px;right: 2px;width: 20px;height: 20px;cursor: pointer;} `); //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 ImgGear = ' '; const SettingFormTmpl = `

dA_FilterNotification Settings

`; //#dA_FN_settings let settingForm; let settings = { filterSide: true, dragSelect: true, updateCss: true, useCustomCss: false, customCss: "",removeSiteNotes:true }; const CSSInsertTMPL = ` div[data-nc] * {visibility: visible;} /* buttons do not vanish*/ div[data-nc] button[data-hook="user_watch_button"] {display: none;} /*removes watch/unwatch buttons*/ [aria-label="Remove"] svg:hover {fill: red !important;} /*unify remove buttons hover color*/ div[data-nc*="favecollect"] > section > div > div:nth-child(2) {display: none;} /*remove activity gallery for new favourites*/ div[data-nc*="new_watcher"] > section > div > div:nth-child(2) {display: none;} /*remove activity gallery for watchers*/ div[data-nc*="badge_given"] > section > div > div:nth-child(2) {display: none;} /*remove activity gallery for Llamas*/ [role="presentation"] {display: none;} /*remove background image from deviation fullview*/ a[data-hook="deviation_link"] img {object-fit: contain;} /*make thumbnails contain full image*/ input[type="checkbox"] + div svg { fill: #0000;} input[type="checkbox"]:checked + div svg { fill: #000F;} ` const Fm = { show: 0, hide: 1, only: 2 }; //filter mode 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: "