Skip to content

Instantly share code, notes, and snippets.

@pacochi
Last active January 24, 2020 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pacochi/fc719fadfca3ceadc4d9eaf81f667517 to your computer and use it in GitHub Desktop.
Save pacochi/fc719fadfca3ceadc4d9eaf81f667517 to your computer and use it in GitHub Desktop.
のてこ?むのはてブ
// ==UserScript==
// @name のてこ?むのはてブ
// @namespace hen.acho.co
// @include https://note.com/*
// @version 1.200125
// @description note.mu 時代のブックマーク数とついでに今のも表示しとく。
// @author pacochi
// @downloadURL https://gist.github.com/pacochi/fc719fadfca3ceadc4d9eaf81f667517/raw/note_bookmark_button.user.js
// @grant none
// ==/UserScript==
// https://b.hatena.ne.jp/guide/bbutton で生成したやつ
document.querySelector('h1').insertAdjacentHTML('afterend', ['com', 'mu'].map(tld => `
<a href="https://b.hatena.ne.jp/entry/s/note.${tld}${location.pathname}" class="hatena-bookmark-button" data-hatena-bookmark-layout="vertical-normal" data-hatena-bookmark-lang="ja" title="このエントリーをはてなブックマークに追加"><img src="https://b.st-hatena.com/images/v4/public/entry-button/button-only@2x.png" alt="このエントリーをはてなブックマークに追加" width="20" height="20" style="border: none;" /></a>
`).join(''));
// なんか読み込めなかった(最初のいっぺんだけ読めた、なぜ…)から実際は bookmark_button.js の中身コピペしてはっつけてる
document.body.appendChild(Object.assign(document.createElement('script'), { src: 'https://b.st-hatena.com/js/bookmark_button.js' } ));
/*
https://bookmark.hatenastaff.com/entry/2019/02/13/105009
>>
HTTPステータスコード301および308によるリダイレクトをしており、リダイレクト先が有効なURLの場合
<<
note.mu は 301 Moved Permanently を返すが Location が https://note.com:443/… になってるせいで統合できてないという仮説。
pixiv が /member_illust.php から /artworks/ に変更したのを思い出してこれの改変で対応しようとしたら既にはてブアドオンに以前までのブックマーク数も表示されていて、あれっそういえばと思って調べたらこんなだった。
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment