// ==UserScript== // @name Qiita Sushi // @namespace https://greasyfork.org/users/432749 // @description QiitaのLGTMアイコンをSushiアイコンに変更する // @author fukuchan // @match https://qiita.com/* // @version 0.0.1.20200313013024 // @downloadURL none // ==/UserScript== /* * OpenSushi * (c) remin */ const viewBox = "0 0 64 64"; const innerHTML = 'tuna'; // SVG要素の中身をSushiに変更する const sushinize = node => { node.setAttribute('viewBox', viewBox); node.innerHTML = innerHTML; }; // ボタンを押すなどして要素に変更があったら再びSushiに変更する const handleObserver = (records, observer) => { observer.disconnect(); sushinize(records[0].target); observer.observe(records[0].target, {attributes: true}); }; // LGTMのSVG要素をそれぞれSushiに変更し、要素の変更を監視する const images = document.querySelectorAll('*[class*="like"] svg, .ItemLink__status svg'); images.forEach(image => { sushinize(image); new MutationObserver(handleObserver).observe(image, {attributes: true}); }); // 文字列のLGTMをSushiに置換する const texts = document.querySelectorAll('.userPopularItems_likeUnit, .notification_actionWrapper span.bold:last-of-type, a[href*=like]'); texts.forEach(text => { text.textContent = text.textContent.replace("LGTM", "Sushi"); });