Last active
May 13, 2021 11:59
-
-
Save peketamin/47586c3d36e9e9f94a1fe5247f53a7aa to your computer and use it in GitHub Desktop.
ブラウザ版はてブのホッテントリリストのタイトル省略を展開するブックマークレット (説明: https://peketamin.hatenablog.jp/entry/2021/05/12/221554)
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
class HatebuLongTitler { | |
constructor () { | |
HatebuLongTitler.makeStyle(); | |
HatebuLongTitler.applyStyle(); | |
} | |
static makeStyle() { | |
const newRule = ` | |
.style-headline:not(.search-url-nothing) .entrylist-main .entrylist-contents-title { | |
white-space: none!important; | |
} | |
`; | |
const style = document.createElement('style'); | |
if(style.styleSheet){ | |
style.styleSheet.cssText = newRule; | |
}else{ | |
style.appendChild(document.createTextNode(newRule)); | |
} | |
document.getElementsByTagName('head')[0].appendChild(style); | |
} | |
static applyStyle() { | |
let titles = document.querySelectorAll(".entrylist-contents-title > a"); | |
for (title of titles) { | |
const longTitle = title.getAttribute("title"); | |
title.innerText = longTitle; | |
title.style.whiteSpace = "normal"; | |
} | |
} | |
} | |
let HBLT = new HatebuLongTitler(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment