blink-star

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

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

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

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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);