diff --git a/dist/pixiv-artist-filter.js b/dist/pixiv-artist-filter.js index f5e4d73..7638074 100644 --- a/dist/pixiv-artist-filter.js +++ b/dist/pixiv-artist-filter.js @@ -1,6 +1,4 @@ -(function(){"use strict";const m=``,{fetch:g}=unsafeWindow;let u=a().map(t=>t.userid);unsafeWindow.fetch=async(...t)=>{const[e,i]=t,n=await g(e,i),r=e;if(r.startsWith("/ajax/search/")){const l=()=>n.clone().json().then(s=>(r.startsWith("/ajax/search/illustrations")?s.body.illust.data=s.body.illust.data.filter(({userId:o})=>!u.includes(o)):(r.startsWith("/ajax/search/top")||r.startsWith("/ajax/search/artworks"))&&(s.body.illustManga.data=s.body.illustManga.data.filter(({userId:o})=>!u.includes(o))),{...s}));n.json=l}return n};function a(){return JSON.parse(GM_getValue("ArtistList","[]"))}function x(t){GM_setValue("ArtistList",JSON.stringify(t)),u=a().map(e=>e.userid)}function f(t,e){const i=a();i.findIndex(n=>n.userid===e)===-1&&(i.push({name:t,userid:e}),x(i))}function h(t){const e=a().filter(i=>i.userid!==t);x(e)}function b(t){if(t.pxv_settings_but)return;t.pxv_settings_but=!0;const e=document.createElement("button");e.id="pxv-artist-filter",e.classList.add("pxv-but","pxv-settings-but"),e.textContent="Artist Filter";const i=()=>{const n=document.createElement("template");let r=a();const l=[];for(const{name:s,userid:o}of r){const d=document.createElement("div"),c=document.createElement("a");c.target="_blank",c.href=`/users/${o}`,c.text=s;const p=document.createElement("button");p.innerHTML=m,p.onclick=()=>{h(o),d.parentNode?.removeChild(d)},d.append(p,c),l.push(d)}return n.append(...l),n.childNodes};e.onclick=()=>{e.blur();const n=document.createElement("template");n.innerHTML=` +(function(){"use strict";const{fetch:g}=unsafeWindow;let p=a().map(t=>t.userid);unsafeWindow.fetch=async(...t)=>{const[e,i]=t,n=await g(e,i),r=e;if(r.startsWith("/ajax/search/")){const l=()=>n.clone().json().then(o=>(r.startsWith("/ajax/search/illustrations")?o.body.illust.data=o.body.illust.data.filter(({userId:s})=>!p.includes(s)):(r.startsWith("/ajax/search/top")||r.startsWith("/ajax/search/artworks"))&&(o.body.illustManga.data=o.body.illustManga.data.filter(({userId:s})=>!p.includes(s))),{...o}));n.json=l}return n};function a(){return JSON.parse(GM_getValue("ArtistList","[]"))}function x(t){GM_setValue("ArtistList",JSON.stringify(t)),p=a().map(e=>e.userid)}function m(t,e){const i=a();i.findIndex(n=>n.userid===e)===-1&&(i.push({name:t,userid:e}),x(i))}function f(t){const e=a().filter(i=>i.userid!==t);x(e)}function b(t){if(t.pxv_settings_but)return;t.pxv_settings_but=!0;const e=document.createElement("button");e.id="pxv-artist-filter",e.classList.add("pxv-but","pxv-settings-but"),e.textContent="Artist Filter";const i=()=>{const n=document.createElement("template");let r=a();const l=[];for(const{name:o,userid:s}of r){const d=document.createElement("div"),c=document.createElement("a");c.target="_blank",c.href=`/users/${s}`,c.text=o;const u=document.createElement("button");u.innerHTML="X",u.title="remove from filter list",u.onclick=()=>{f(s),d.parentNode?.removeChild(d)},d.append(u,c),l.push(d)}return n.append(...l),n.childNodes};e.onclick=()=>{e.blur();const n=document.createElement("template");n.innerHTML=`

Artist Filter List

@@ -11,7 +9,7 @@ C6.1204 19.5586 6.56641 20 7.11464 20H17C17.5523 20 18 19.5523 18 19V9C18 8.4477
- `;const r=n.content.firstElementChild;(r?.getElementsByClassName("pxv-artist-grid").item(0)).replaceChildren(...i());const s=r?.getElementsByClassName("pxv-but").item(0);s.onclick=()=>document.body.removeChild(r),document.body.appendChild(r)},t.parentNode.insertBefore(e,t.nextSibling)}function v(t){if(t.pxv_fil_but)return;t.pxv_fil_but=!0;const e=t.parentElement?.querySelector("div a[data-gtm-value]:not(:has(*))"),i=document.createElement("button");i.id="pxv-artist-filter",i.classList.add("pxv-but","pxv-modal-filter-but"),i.textContent="Filter",i.onclick=()=>{if(confirm(`Do you want to filter ${e.text}'s posts ?`)){const n=e.text,r=e.getAttribute("data-gtm-value")||"-1";f(n,r),alert(`${e.text} has been added to the filter list.`)}},t.appendChild(i)}function _(){GM_addStyle(` + `;const r=n.content.firstElementChild;(r?.getElementsByClassName("pxv-artist-grid").item(0)).replaceChildren(...i());const o=r?.getElementsByClassName("pxv-but").item(0);o.onclick=()=>document.body.removeChild(r),document.body.appendChild(r)},t.parentNode.insertBefore(e,t.nextSibling)}function v(t){if(t.pxv_fil_but)return;t.pxv_fil_but=!0;const e=t.parentElement?.querySelector("div a[data-gtm-value]:not(:has(*))"),i=document.createElement("button");i.id="pxv-artist-filter",i.classList.add("pxv-but","pxv-modal-filter-but"),i.textContent="Filter",i.onclick=()=>{if(confirm(`Do you want to filter ${e.text}'s posts ?`)){const n=e.text,r=e.getAttribute("data-gtm-value")||"-1";m(n,r),alert(`${e.text} has been added to the filter list.`)}},t.appendChild(i)}function h(){GM_addStyle(` .pxv-but { color: rgb(245, 245, 245); background-color: rgb(0, 150, 250); @@ -94,16 +92,20 @@ C6.1204 19.5586 6.56641 20 7.11464 20H17C17.5523 20 18 19.5523 18 19V9C18 8.4477 .pxv-artist-grid > div > button { margin: 0 5px; + width: 20px; padding: 0px; - border: medium; outline: none; background: transparent; cursor: pointer; color: rgb(133, 133, 133); } + + .pxv-artist-grid > div > button:hover { + color: rgb(255, 255, 255); + } .pxv-artist-grid > div > a { flex-grow:1; margin: auto 0; } - `),setInterval(()=>{if(window.location.pathname!=="/search")return;const t=document.getElementsByTagName("nav").item(2);t&&b(t)},1e3),setInterval(()=>{if(window.location.pathname!=="/search")return;const t=document.evaluate("//*/div[@open='']",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE);t.singleNodeValue&&v(t.singleNodeValue)},1e3)}_()})(); + `),setInterval(()=>{if(window.location.pathname!=="/search")return;const t=document.getElementsByTagName("nav").item(2);t&&b(t)},1e3),setInterval(()=>{if(window.location.pathname!=="/search")return;const t=document.evaluate("//*/div[@open='']",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE);t.singleNodeValue&&v(t.singleNodeValue)},1e3)}h()})(); diff --git a/dist/pixiv-artist-filter.meta.js b/dist/pixiv-artist-filter.meta.js index c4304e9..d0830ed 100644 --- a/dist/pixiv-artist-filter.meta.js +++ b/dist/pixiv-artist-filter.meta.js @@ -1,7 +1,7 @@ // ==UserScript== // @name pixiv-artist-filter // @description filter unwanted artists from pixiv results -// @version 0.0.2 +// @version 0.0.3 // @namespace noproompter // @match https://www.pixiv.net/* // @noframes diff --git a/dist/pixiv-artist-filter.user.js b/dist/pixiv-artist-filter.user.js index 5d355ea..217b328 100644 --- a/dist/pixiv-artist-filter.user.js +++ b/dist/pixiv-artist-filter.user.js @@ -1,7 +1,7 @@ // ==UserScript== // @name pixiv-artist-filter // @description filter unwanted artists from pixiv results -// @version 0.0.2 +// @version 0.0.3 // @namespace noproompter // @match https://www.pixiv.net/* // @noframes @@ -16,9 +16,7 @@ // @grant GM.addElement // ==/UserScript== -(function(){"use strict";const m=``,{fetch:g}=unsafeWindow;let u=a().map(t=>t.userid);unsafeWindow.fetch=async(...t)=>{const[e,i]=t,n=await g(e,i),r=e;if(r.startsWith("/ajax/search/")){const l=()=>n.clone().json().then(s=>(r.startsWith("/ajax/search/illustrations")?s.body.illust.data=s.body.illust.data.filter(({userId:o})=>!u.includes(o)):(r.startsWith("/ajax/search/top")||r.startsWith("/ajax/search/artworks"))&&(s.body.illustManga.data=s.body.illustManga.data.filter(({userId:o})=>!u.includes(o))),{...s}));n.json=l}return n};function a(){return JSON.parse(GM_getValue("ArtistList","[]"))}function x(t){GM_setValue("ArtistList",JSON.stringify(t)),u=a().map(e=>e.userid)}function f(t,e){const i=a();i.findIndex(n=>n.userid===e)===-1&&(i.push({name:t,userid:e}),x(i))}function h(t){const e=a().filter(i=>i.userid!==t);x(e)}function b(t){if(t.pxv_settings_but)return;t.pxv_settings_but=!0;const e=document.createElement("button");e.id="pxv-artist-filter",e.classList.add("pxv-but","pxv-settings-but"),e.textContent="Artist Filter";const i=()=>{const n=document.createElement("template");let r=a();const l=[];for(const{name:s,userid:o}of r){const d=document.createElement("div"),c=document.createElement("a");c.target="_blank",c.href=`/users/${o}`,c.text=s;const p=document.createElement("button");p.innerHTML=m,p.onclick=()=>{h(o),d.parentNode?.removeChild(d)},d.append(p,c),l.push(d)}return n.append(...l),n.childNodes};e.onclick=()=>{e.blur();const n=document.createElement("template");n.innerHTML=` +(function(){"use strict";const{fetch:g}=unsafeWindow;let p=a().map(t=>t.userid);unsafeWindow.fetch=async(...t)=>{const[e,i]=t,n=await g(e,i),r=e;if(r.startsWith("/ajax/search/")){const l=()=>n.clone().json().then(o=>(r.startsWith("/ajax/search/illustrations")?o.body.illust.data=o.body.illust.data.filter(({userId:s})=>!p.includes(s)):(r.startsWith("/ajax/search/top")||r.startsWith("/ajax/search/artworks"))&&(o.body.illustManga.data=o.body.illustManga.data.filter(({userId:s})=>!p.includes(s))),{...o}));n.json=l}return n};function a(){return JSON.parse(GM_getValue("ArtistList","[]"))}function x(t){GM_setValue("ArtistList",JSON.stringify(t)),p=a().map(e=>e.userid)}function m(t,e){const i=a();i.findIndex(n=>n.userid===e)===-1&&(i.push({name:t,userid:e}),x(i))}function f(t){const e=a().filter(i=>i.userid!==t);x(e)}function b(t){if(t.pxv_settings_but)return;t.pxv_settings_but=!0;const e=document.createElement("button");e.id="pxv-artist-filter",e.classList.add("pxv-but","pxv-settings-but"),e.textContent="Artist Filter";const i=()=>{const n=document.createElement("template");let r=a();const l=[];for(const{name:o,userid:s}of r){const d=document.createElement("div"),c=document.createElement("a");c.target="_blank",c.href=`/users/${s}`,c.text=o;const u=document.createElement("button");u.innerHTML="X",u.title="remove from filter list",u.onclick=()=>{f(s),d.parentNode?.removeChild(d)},d.append(u,c),l.push(d)}return n.append(...l),n.childNodes};e.onclick=()=>{e.blur();const n=document.createElement("template");n.innerHTML=`

Artist Filter List

@@ -29,7 +27,7 @@ C6.1204 19.5586 6.56641 20 7.11464 20H17C17.5523 20 18 19.5523 18 19V9C18 8.4477
- `;const r=n.content.firstElementChild;(r?.getElementsByClassName("pxv-artist-grid").item(0)).replaceChildren(...i());const s=r?.getElementsByClassName("pxv-but").item(0);s.onclick=()=>document.body.removeChild(r),document.body.appendChild(r)},t.parentNode.insertBefore(e,t.nextSibling)}function v(t){if(t.pxv_fil_but)return;t.pxv_fil_but=!0;const e=t.parentElement?.querySelector("div a[data-gtm-value]:not(:has(*))"),i=document.createElement("button");i.id="pxv-artist-filter",i.classList.add("pxv-but","pxv-modal-filter-but"),i.textContent="Filter",i.onclick=()=>{if(confirm(`Do you want to filter ${e.text}'s posts ?`)){const n=e.text,r=e.getAttribute("data-gtm-value")||"-1";f(n,r),alert(`${e.text} has been added to the filter list.`)}},t.appendChild(i)}function _(){GM_addStyle(` + `;const r=n.content.firstElementChild;(r?.getElementsByClassName("pxv-artist-grid").item(0)).replaceChildren(...i());const o=r?.getElementsByClassName("pxv-but").item(0);o.onclick=()=>document.body.removeChild(r),document.body.appendChild(r)},t.parentNode.insertBefore(e,t.nextSibling)}function v(t){if(t.pxv_fil_but)return;t.pxv_fil_but=!0;const e=t.parentElement?.querySelector("div a[data-gtm-value]:not(:has(*))"),i=document.createElement("button");i.id="pxv-artist-filter",i.classList.add("pxv-but","pxv-modal-filter-but"),i.textContent="Filter",i.onclick=()=>{if(confirm(`Do you want to filter ${e.text}'s posts ?`)){const n=e.text,r=e.getAttribute("data-gtm-value")||"-1";m(n,r),alert(`${e.text} has been added to the filter list.`)}},t.appendChild(i)}function h(){GM_addStyle(` .pxv-but { color: rgb(245, 245, 245); background-color: rgb(0, 150, 250); @@ -112,16 +110,20 @@ C6.1204 19.5586 6.56641 20 7.11464 20H17C17.5523 20 18 19.5523 18 19V9C18 8.4477 .pxv-artist-grid > div > button { margin: 0 5px; + width: 20px; padding: 0px; - border: medium; outline: none; background: transparent; cursor: pointer; color: rgb(133, 133, 133); } + + .pxv-artist-grid > div > button:hover { + color: rgb(255, 255, 255); + } .pxv-artist-grid > div > a { flex-grow:1; margin: auto 0; } - `),setInterval(()=>{if(window.location.pathname!=="/search")return;const t=document.getElementsByTagName("nav").item(2);t&&b(t)},1e3),setInterval(()=>{if(window.location.pathname!=="/search")return;const t=document.evaluate("//*/div[@open='']",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE);t.singleNodeValue&&v(t.singleNodeValue)},1e3)}_()})(); + `),setInterval(()=>{if(window.location.pathname!=="/search")return;const t=document.getElementsByTagName("nav").item(2);t&&b(t)},1e3),setInterval(()=>{if(window.location.pathname!=="/search")return;const t=document.evaluate("//*/div[@open='']",document,null,XPathResult.FIRST_ORDERED_NODE_TYPE);t.singleNodeValue&&v(t.singleNodeValue)},1e3)}h()})(); diff --git a/package.json b/package.json index 2edc964..43a65c3 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { "name": "pixiv-artist-filter", "description": "filter unwanted artists from pixiv results", - "version":"0.0.2" + "version":"0.0.3" } diff --git a/src/main.ts b/src/main.ts index f85cb6f..9d6e065 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,8 +1,5 @@ import type { AjaxSearchResponse } from './AjaxSearchResponse.ts'; import type { Artist } from './ArtistFilter.ts'; - -import { TrashIcon } from './trashIcon.ts'; - const { fetch: originalFetch } = unsafeWindow; let ArtistIdList: string[] = artist_list_load().map(x => x.userid) @@ -94,7 +91,8 @@ function AttachSettings(NavNode:HTMLElement) { artist_name.text = name; const del_but = document.createElement('button'); - del_but.innerHTML = TrashIcon; + del_but.innerHTML = "X"; + del_but.title = "remove from filter list"; del_but.onclick = () => { delArtist(userid); item.parentNode?.removeChild(item); @@ -253,13 +251,17 @@ function init() { .pxv-artist-grid > div > button { margin: 0 5px; + width: 20px; padding: 0px; - border: medium; outline: none; background: transparent; cursor: pointer; color: rgb(133, 133, 133); } + + .pxv-artist-grid > div > button:hover { + color: rgb(255, 255, 255); + } .pxv-artist-grid > div > a { flex-grow:1;