blink-star

はてなブックマークにて、自分が付けたスターを点滅させて見分けがつくようにします。

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(Tôi đã có Trình quản lý tập lệnh người dùng, hãy cài đặt nó!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        blink-star
// @namespace   jp.hateblo.htsign
// @description はてなブックマークにて、自分が付けたスターを点滅させて見分けがつくようにします。
// @match       http://b.hatena.ne.jp/*
// @match       https://b.hatena.ne.jp/*
// @version     1.0.8
// @grant       none
// ==/UserScript==

(async g => {
  const root = g.document.documentElement;
  if (!root || !root.dataset.pageScope) return;

  const res = await fetch(`${g.origin}/api/my/profile`, { credentials: 'include' });
  const { status, name } = await res.json();
  if (status !== 1) return;

  const style = g.document.createElement('style');
  g.document.head.appendChild(style);

  style.sheet.insertRule(`
    @keyframes blink-star {
      from { opacity: 1.0 }
      to   { opacity: 0.3 }
    }`);
  style.sheet.insertRule(`
    a.hatena-star-star[href$="/${name}"] {
      animation: blink-star 300ms infinite ease-in alternate;
    }`);
})(window);