Skip to content

Instantly share code, notes, and snippets.

@Getaji
Last active February 20, 2023 17:02
Show Gist options
  • Save Getaji/59e39d57082ffccadec2f9b7fae28dab to your computer and use it in GitHub Desktop.
Save Getaji/59e39d57082ffccadec2f9b7fae28dab to your computer and use it in GitHub Desktop.
(_ => {
const favEl = document.querySelector("section ul li>div>div:nth-child(2)>div>div:last-child>div>div:last-child>div>span:nth-child(3)");
if (!favEl) {
alert("♥要素を取得できません");
return;
}
const selector = [...favEl.classList].map((cls) => "." + cls).join("") + ":last-child";
console.log("♥数ハイライトセレクタ:", selector);
const heartAmountEls = document.querySelectorAll(selector);
if (!heartAmountEls.length) {
alert("♥数を取得できません。セレクタを確認してください。");
return;
}
const threshold = parseInt(prompt("しきい値(指定値を含む)", "100"));
if (isNaN(threshold)) return;
console.log("♥数ハイライトしきい値:", threshold);
Array.prototype.forEach.call(heartAmountEls, (el) => {
const value = parseInt(el.innerText.replace(/,/g, ""));
if (isNaN(value)) return;
if (value >= threshold) {
el.style.color = "#ff7be9";
el.style.fontWeight = "#bold";
}
});
})()
(t=>{const l=document.querySelector("section ul li>div>div:nth-child(2)>div>div:last-child>div>div:last-child>div>span:nth-child(3)");if(!l)return void alert("♥要素を取得できません");const e=[...l.classList].map((t=>"."+t)).join("")+":last-child";console.log("♥数ハイライトセレクタ:",e);const o=document.querySelectorAll(e);if(!o.length)return void alert("♥数を取得できません。セレクタを確認してください。");const i=parseInt(prompt("しきい値(指定値を含む)","100"));isNaN(i)||(console.log("♥数ハイライトしきい値:",i),Array.prototype.forEach.call(o,(t=>{const l=parseInt(t.innerText.replace(/,/g,""));isNaN(l)||l>=i&&(t.style.color="#ff7be9",t.style.fontWeight="#bold")})))})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment