Skip to content

Instantly share code, notes, and snippets.

@peketamin
Last active May 13, 2021 11:59
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 peketamin/47586c3d36e9e9f94a1fe5247f53a7aa to your computer and use it in GitHub Desktop.
Save peketamin/47586c3d36e9e9f94a1fe5247f53a7aa to your computer and use it in GitHub Desktop.
ブラウザ版はてブのホッテントリリストのタイトル省略を展開するブックマークレット (説明: https://peketamin.hatenablog.jp/entry/2021/05/12/221554)
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