anilist-nolife

Quality of no life improvement on AniList

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name anilist-nolife
// @description Quality of no life improvement on AniList
// @version 0.1.2
// @author gnir
// @homepage https://github.com/gnir-gh
// @match https://anilist.co/*
// @namespace https://greasyfork.org/users/1095901
// ==/UserScript==

(()=>{var t={815:t=>{let e={_call:function(t,...e){console[t]("[gnir]",...e)},info:function(...t){this._call("info",...t)},error:function(...t){this._call("error",...t)},log:function(...t){this._call("log",...t)}};t.exports=e}},e={};function n(r){var i=e[r];if(void 0!==i)return i.exports;var a=e[r]={exports:{}};return t[r](a,a.exports,n),a.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{"use strict";var t=n(815),e=n.n(t);function r(t,e,n=200,i=document){const a=i.querySelector(t);null!==a?e(a):setTimeout((function(){r(t,e,n,i)}),n)}function i(t,e,n,...r){if(function(t,e){return"childList"===e.type&&e.addedNodes.length>0&&e.target.matches(t)}(t,e))for(const t of e.addedNodes)t.nodeName.startsWith("#")||n(t,e.target,...r)}function a(t,e,n,...r){if(function(t,e){return"childList"===e.type&&e.removedNodes.length>0&&e.target.matches(t)}(t,e))for(const t of e.removedNodes)t.nodeName.startsWith("#")||n(t,e.target,...r)}function o(t,e,n=!1,r=!0){const i=t.value.slice(0,t.selectionStart),a=t.value.slice(t.selectionEnd);!1!==n&&![" ","\n"].includes(i.slice(-1))&&i.length>0&&("string"!=typeof n&&(n=" "),e=n+e);const o=i+e;t.value=o+a,t.focus(),t.selectionEnd=o.length,r&&t.dispatchEvent(new Event("input",{cancelable:!1,composed:!0}))}const c="object"==typeof global&&global&&global.Object===Object&&global;var u="object"==typeof self&&self&&self.Object===Object&&self;const s=c||u||Function("return this")(),l=s.Symbol,d=Array.isArray;var f=Object.prototype,m=f.hasOwnProperty,g=f.toString,p=l?l.toStringTag:void 0;var h=Object.prototype.toString;var v=l?l.toStringTag:void 0;const y=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":v&&v in Object(t)?function(t){var e=m.call(t,p),n=t[p];try{t[p]=void 0;var r=!0}catch(t){}var i=g.call(t);return r&&(e?t[p]=n:delete t[p]),i}(t):function(t){return h.call(t)}(t)},_=function(t){return"symbol"==typeof t||function(t){return null!=t&&"object"==typeof t}(t)&&"[object Symbol]"==y(t)};var b=l?l.prototype:void 0,T=b?b.toString:void 0;const w=function t(e){if("string"==typeof e)return e;if(d(e))return function(t,e){for(var n=-1,r=null==t?0:t.length,i=Array(r);++n<r;)i[n]=e(t[n],n,t);return i}(e,t)+"";if(_(e))return T?T.call(e):"";var n=e+"";return"0"==n&&1/e==-1/0?"-0":n},E=function(t){return null==t?"":w(t)},j=function(t,e,n){var r=t.length;return n=void 0===n?r:n,!e&&n>=r?t:function(t,e,n){var r=-1,i=t.length;e<0&&(e=-e>i?0:i+e),(n=n>i?i:n)<0&&(n+=i),i=e>n?0:n-e>>>0,e>>>=0;for(var a=Array(i);++r<i;)a[r]=t[r+e];return a}(t,e,n)};var S=RegExp("[\\u200d\\ud800-\\udfff\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff\\ufe0e\\ufe0f]");const x=function(t){return S.test(t)};var A="\\ud800-\\udfff",k="["+A+"]",L="[\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff]",O="\\ud83c[\\udffb-\\udfff]",$="[^"+A+"]",N="(?:\\ud83c[\\udde6-\\uddff]){2}",M="[\\ud800-\\udbff][\\udc00-\\udfff]",q="(?:"+L+"|"+O+")?",P="[\\ufe0e\\ufe0f]?",C=P+q+"(?:\\u200d(?:"+[$,N,M].join("|")+")"+P+q+")*",H="(?:"+[$+L+"?",L,N,M,k].join("|")+")",I=RegExp(O+"(?="+O+")|"+H+C,"g");const z=function(t){return x(t)?function(t){return t.match(I)||[]}(t):function(t){return t.split("")}(t)},R=function(t){t=E(t);var e=x(t)?z(t):void 0,n=e?e[0]:t.charAt(0),r=e?j(e,1).join(""):t.slice(1);return n.toUpperCase()+r};const U=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},V=function(){return s.Date.now()};var W=/\s/;var F=/^\s+/;const D=function(t){return t?t.slice(0,function(t){for(var e=t.length;e--&&W.test(t.charAt(e)););return e}(t)+1).replace(F,""):t};var B=/^[-+]0x[0-9a-f]+$/i,G=/^0b[01]+$/i,J=/^0o[0-7]+$/i,K=parseInt;const Q=function(t){if("number"==typeof t)return t;if(_(t))return NaN;if(U(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=U(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=D(t);var n=G.test(t);return n||J.test(t)?K(t.slice(2),n?2:8):B.test(t)?NaN:+t};var X=Math.max,Y=Math.min;const Z=function(t){const e={thread:["thread","thread:comment"],activityFeed:["home","user","activity"],bigEditor:["thread:editor","review"]};function n(t,e,n,r=!1){t.preventDefault?.();const i=n.firstElementChild,a=e.getAttribute("data-url"),c=e.getAttribute("data-romaji");r?o(i,`[${c}](${a})`," ",!0):o(i,a+"\n","\n",!0)}function c(t){t.innerHTML='<span style="font-size: 1.2rem; padding: 1rem;">No anime/manga found.</span>'}function u(t){t.innerHTML="Click on the cover image to insert link. Right-click to insert linked title."}function s(t,e,n){const r=(i=e.getAttribute("data-format"),["OVA","ONA"].includes(i)?i:"TV_SHORT"===i?"TV Short":"TV"===i?"TV":"ONE_SHOT"===i?"Oneshot":R(E(i).toLowerCase()));var i;const a=e.getAttribute("data-romaji"),o=e.getAttribute("data-english");n.innerHTML=`[${r}] ${a}`,"null"!==o&&(n.innerHTML+=` (${o})`)}async function l(t,e,r,i){const a=t.value,o=r.querySelector(".gn_media-search__results");if(""===a)return void(o.innerHTML="");let l=[],d=!1;const f=e.querySelectorAll('input[type="checkbox"]');for(const t of f)t.classList.contains("gn_media-search__format")&&t?.checked?l.push(t.value):t.classList.contains("gn_media-search__adult")&&(d=t.checked);if(0===l.length)return void c(o);const m=await async function(t,e,n){let r={search:t,perPage:8},i="",a="";1===e?.length&&(i+=", $mediaType: MediaType",a+=", type: $mediaType",r.mediaType=e[0].toUpperCase().trim()),!1===n&&(i+=", $adult: Boolean",a+=", isAdult: $adult",r.adult=n);const o=`query ($perPage: Int, $search: String${i}) {\n\t\tPage (page: 1, perPage: $perPage) {\n\t\t  pageInfo {\n\t\t\ttotal\n\t\t\tperPage\n\t\t  }\n\t\t  media (search: $search${a}) {\n\t\t\tid\n\t\t\ttype,\n\t\t\ttitle {\n\t\t\t  romaji\n\t\t\t  english\n\t\t\t},\n\t\t\tformat,\n\t\t\tcoverImage {\n\t\t\t  medium\n\t\t\t}\n\t\t  }\n\t\t}\n\t  }`;return(await async function(t,e){return async function(t,e){try{const t=await fetch("https://graphql.anilist.co",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},...e});if(!t.ok)throw new Error(t.statusText);return await t.json()}catch(t){console.error(t)}}(0,{body:JSON.stringify({query:t,variables:e})})}(o,r)).data}(a,l,d);if(m.Page.pageInfo.total>0){o.innerHTML="";const t=m.Page.media,e=document.createElement("div");e.classList.add("gn_media-search__infobar"),o.append(e),u(e);const r=document.createElement("ul");for(const a of t){let t=document.createElement("li");t.setAttribute("style",`background-image: url("${a.coverImage.medium}")`),t.setAttribute("data-romaji",a.title.romaji),t.setAttribute("data-type",a.type),t.setAttribute("data-format",a.format),t.setAttribute("data-english",a.title.english),t.setAttribute("data-url",`https://anilist.co/${a.type.toLowerCase()}/${a.id}`),r.append(t),t.addEventListener("click",(t=>{n(t,t.currentTarget,i)})),t.addEventListener("contextmenu",(t=>{n(t,t.currentTarget,i,!0)})),t.addEventListener("mouseover",(t=>{s(0,t.currentTarget,e)})),t.addEventListener("mouseout",(t=>{u(e)}))}o.prepend(r)}else c(o)}function d(t){if(null===t)return;if(function(t){return null!==t.parentElement.querySelector(".gn_media-search")}(t))return;const e=t.nextElementSibling,n=function(t){let e=document.createElement("div");return e.innerHTML='<div class="gn_media-search">\n\t\t\t<div class="gn_media-search__searchbar">\n\t\t\t\t<div class="gn_media-search__input-wrapper el-input">\n\t\t\t\t\t<input class="el-input__inner gn_media-search__input" placeholder="Search for media ..." />\n\t\t\t\t</div>\n\t\t\t\t<div class="gn_media-search__options">\n\t\t\t\t\t<label><input type="checkbox" class="gn_media-search__format" value="ANIME" checked> Anime</label>\n\t\t\t\t\t<label><input type="checkbox" class="gn_media-search__format" value="MANGA" checked> Manga</label>\n\t\t\t\t\t<label><input type="checkbox" class="gn_media-search__adult" value="18+"> 18+</label>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t<div class="gn_media-search__results">\n\t\t\t</div>\n\t\t</div>',e.firstElementChild}();e.after(n);const r=n.querySelector(".gn_media-search__input"),i=n.querySelector(".gn_media-search__options"),a=function(t,e,n){var r,i,a,o,c,u,s=0,l=!1,d=!1,f=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function m(e){var n=r,a=i;return r=i=void 0,s=e,o=t.apply(a,n)}function g(t){var n=t-u;return void 0===u||n>=e||n<0||d&&t-s>=a}function p(){var t=V();if(g(t))return h(t);c=setTimeout(p,function(t){var n=e-(t-u);return d?Y(n,a-(t-s)):n}(t))}function h(t){return c=void 0,f&&r?m(t):(r=i=void 0,o)}function v(){var t=V(),n=g(t);if(r=arguments,i=this,u=t,n){if(void 0===c)return function(t){return s=t,c=setTimeout(p,e),l?m(t):o}(u);if(d)return clearTimeout(c),c=setTimeout(p,e),m(u)}return void 0===c&&(c=setTimeout(p,e)),o}return e=Q(e)||0,U(n)&&(l=!!n.leading,a=(d="maxWait"in n)?X(Q(n.maxWait)||0,e):a,f="trailing"in n?!!n.trailing:f),v.cancel=function(){void 0!==c&&clearTimeout(c),s=0,r=u=i=c=void 0},v.flush=function(){return void 0===c?o:h(V())},v}(l,250,{maxWait:500});r.addEventListener("keyup",(t=>{a(r,i,n,e)})),i.addEventListener("change",(t=>{a(r,i,n,e)}))}if(e.thread.includes(t))r(".comment-editor",(function(t){const e=document.querySelector(".comment-editor .markdown-editor");null!==e&&d(e),new MutationObserver(((t,e)=>{for(const e of t)i(".comment-editor",e,((t,e)=>{d(e.querySelector(".markdown-editor"))}))})).observe(t,{childList:!0,subtree:!0})}));else if(e.activityFeed.includes(t)){let e=".activity-feed-wrap";"activity"===t&&(e=".activity-entry"),r(e,(function(t){const e=document.querySelectorAll(".activity-edit .markdown-editor, .activity-entry .markdown-editor");for(const t of e)null!==t.parentElement.querySelector(".actions")&&d(t);new MutationObserver(((t,e)=>{for(const e of t)i(".activity-edit, .activity-entry",e,((t,e)=>{d(e.querySelector(".markdown-editor"))})),a(".activity-edit, .activity-entry",e,((t,e)=>{var n;t.classList.contains("actions")&&(n=e,n.querySelector(".gn_media-search")?.remove())}))})).observe(t,{childList:!0,subtree:!0})}))}else e.bigEditor.includes(t)&&r(".body .markdown-editor",(function(t){d(t)}))};let tt="";const et=function(){tt=document.URL;const t=function(){const t=window.location.pathname.split("/");let e=t[1];return"forum"===e?"thread"===t?.[2]&&(e="thread","comment"===t?.[4]?e+=":comment":"editor"===t?.[3]&&(e+=":editor")):"settings"===e&&""!==t?.[2]&&(e+=`:${t[2]}`),e}();Z(t),function(t){"settings:apps"===t&&r(".content .apps",(t=>{document.createElement("div")}))}(t)};!function(){let t=document.createElement("style");t.textContent="\n.reply .header .gn_at-button {\n\tmargin-top: 0.5em;\n\tvertical-align: top;\n}\n.forum-thread .body .gn_at-button {\n\theight: 2.5em;\n}\n\n.activity-edit .gn_media-search {\n\tmargin-bottom: 1rem;\n}\n.activity-edit .gn_media-search {\n\tmargin-top: -1rem;\n}\n.gn_media-search__searchbar {\n\tdisplay: grid;\n\tgrid-template-columns: 1fr auto;\n\tcolumn-gap: 1rem;\n\tfont-size: 1.3rem;\n\tplace-items: center;\n}\n\n.gn_media-search__input {\n\tfont-size: 1.3rem;\n\tmax-height: 36px;\n}\n\n.thread .body .gn_media-search__input,\n.review .body .gn_media-search__input,\n.forum-thread .gn_media-search__input {\n\tbox-shadow: none !important;\n}\n.gn_media-search__options label {\n\tmargin-right: 0.5rem;\n}\n.gn_media-search__results label:last-child {\n\tmargin-right: 0;\n}\n.gn_media-search__results {\n\tmargin-top: 1rem;\n\tbox-sizing: border-box;\n}\n.gn_media-search__infobar {\n\tfont-size: 1rem;\n}\n.gn_media-search__results ul {\n\tmargin: 0;\n\tpadding: 0;\n}\n.gn_media-search__results li {\n\tbackground-position: 50%;\n\tbackground-size: cover;\n\tcursor: pointer;\n\tborder-radius: 3px;\n\tdisplay: inline-block;\n\twidth: 4rem;\n\theight: 4rem;\n\tmargin-right: 1rem;\n}\n.gn_media-search__reslts li:last-child {\n\tmargin-right: 0;\n}\n",document.head.append(t),e().info("injected style")}(),et(),setInterval((()=>{let t=document.URL;tt!==t&&et()}),200)})()})();