Pitchfork Score Reveal
by
yuta25
05/11 [2026/05/11 10:39:41]
サブスクで隠されている Pitchfork のスコアを表示する
@@ -9,7 +9,7 @@
// ==UserScript==
// @name Pitchfork Score Reveal
// @namespace https://github.com/dlwr/pitchfork-score
-// @version 1.0.0
+// @version 1.0.2
// @description サブスクで隠されている Pitchfork のスコアを表示する
// @match https://pitchfork.com/reviews/albums/*
// @run-at document-end
@@ -17,24 +17,19 @@
// ==/UserScript==
(() => {
- const reveal = () => {
- const s =
- window.__PRELOADED_STATE__?.transformed?.review?.headerProps?.musicRating
- ?.score;
- if (s === undefined || s === null || s === "") {
- alert("Pitchfork のレビューページじゃないか、データ構造が変わってるじゃん");
- return;
- }
+ const getScore = () =>
+ window.__PRELOADED_STATE__?.transformed?.review?.headerProps?.musicRating
+ ?.score;
+
+ const apply = (score) => {
const p = document.querySelector(
'[class*="SplitScreenContentHeaderScoreBox"] p',
);
- if (!p) {
- alert(
- "スコア: " + s + "(DOM に挿入できんかった。セレクタを更新する必要あり)",
- );
- return;
+ if (!p) return false;
+ const text = String(score);
+ if (p.textContent !== text) {
+ p.textContent = text;
}
- p.textContent = String(s);
let el = p;
while (el) {
const f = getComputedStyle(el).filter;
@@ -43,11 +38,38 @@
}
el = el.parentElement;
}
+ return true;
+ };
+
+ const start = () => {
+ const score = getScore();
+ if (score === undefined || score === null || score === "") {
+ alert(
+ "Pitchfork のレビューページじゃないか、データ構造が変わってるじゃん",
+ );
+ return;
+ }
+ if (!apply(score)) {
+ alert(
+ "スコア: " +
+ score +
+ "(DOM に挿入できんかった。セレクタを更新する必要あり)",
+ );
+ return;
+ }
+ const observer = new MutationObserver(() => apply(score));
+ observer.observe(document.body, {
+ subtree: true,
+ childList: true,
+ characterData: true,
+ attributes: true,
+ attributeFilter: ["class", "style"],
+ });
};
if (document.readyState === "loading") {
- document.addEventListener("DOMContentLoaded", reveal);
+ document.addEventListener("DOMContentLoaded", start);
} else {
- reveal();
+ start();
}
})();
/*
* @title Pitchfork Score Reveal
* @description サブスクで隠されている Pitchfork のスコアを表示する
* @include https://pitchfork.com/reviews/albums/*
* @license MIT License
* @require
*/
// ==UserScript==
// @name Pitchfork Score Reveal
// @namespace https://github.com/dlwr/pitchfork-score
// @version 1.0.2
// @description サブスクで隠されている Pitchfork のスコアを表示する
// @match https://pitchfork.com/reviews/albums/*
// @run-at document-end
// @grant none
// ==/UserScript==
(() => {
const getScore = () =>
window.__PRELOADED_STATE__?.transformed?.review?.headerProps?.musicRating
?.score;
const apply = (score) => {
const p = document.querySelector(
'[class*="SplitScreenContentHeaderScoreBox"] p',
);
if (!p) return false;
const text = String(score);
if (p.textContent !== text) {
p.textContent = text;
}
let el = p;
while (el) {
const f = getComputedStyle(el).filter;
if (f && f.includes("blur")) {
el.style.filter = "none";
}
el = el.parentElement;
}
return true;
};
const start = () => {
const score = getScore();
if (score === undefined || score === null || score === "") {
alert(
"Pitchfork のレビューページじゃないか、データ構造が変わってるじゃん",
);
return;
}
if (!apply(score)) {
alert(
"スコア: " +
score +
"(DOM に挿入できんかった。セレクタを更新する必要あり)",
);
return;
}
const observer = new MutationObserver(() => apply(score));
observer.observe(document.body, {
subtree: true,
childList: true,
characterData: true,
attributes: true,
attributeFilter: ["class", "style"],
});
};
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", start);
} else {
start();
}
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。