Last active
August 22, 2017 03:41
-
-
Save khsk/1e7dd3d6beb21da52e4e18b310202392 to your computer and use it in GitHub Desktop.
新はてなブックマークで本文をトップに表示する&お気に入りユーザーのコメントをポップアップさせるユーザースクリプト ref: http://qiita.com/khsk/items/5ae8b489a8f16cf637b8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name move entory-about to top | |
// @namespace khsk | |
// @description 本文とタグをトップに移動 | |
// @include http://b.hatena.ne.jp/entry/* | |
// @include https://b.hatena.ne.jp/entry/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
const ea = document.querySelector('section.entry-about'); | |
const emb = document.querySelector('div.entry-myBookmark'); | |
emb.parentNode.insertBefore(ea.cloneNode(true), emb); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name popup favorite users comment | |
// @namespace khsk | |
// @include http://b.hatena.ne.jp/entry/* | |
// @include https://b.hatena.ne.jp/entry/* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
const target = document.querySelector('ul.entry-info-favorite'); | |
if (!target){ | |
return; | |
} | |
const observer = new MutationObserver((mutations) => { | |
mutations[0].target.querySelectorAll('li').forEach((li) => { | |
const popup = li.querySelector('span') | |
popup.innerText += ' \n ' + li.dataset.bookmarkComment + '\n\n' + li.dataset.bookmarkTags; | |
// 後から追記すると最初の\nによる<br>が削除される謎現象が起きているので空タグでも改行をつけることにする↑ | |
// if (li.dataset.bookmarkTags) { | |
// popup.innerText += '\n\n' + li.dataset.bookmarkTags; | |
// } | |
// ここきれいにアイコンの上付きできないからなんとかして 適当に大きくしとくね | |
popup.style.top = '-135px'; | |
popup.style.width = '165px'; | |
// 個人的 横幅が狭いと最初のポップアップが見切れるから右にプラス移動 上下合わせて微調整は個人で | |
popup.style.right = 0 | |
popup.style.left = 0 | |
}); | |
observer.disconnect(); | |
}); | |
const config = { attributes: true, /*attributeFilter: ['children'],*/childList: true, }; | |
observer.observe(target, config); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment