Skip to content

Instantly share code, notes, and snippets.

@hidao80
Last active June 2, 2022 04:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hidao80/4136e4bd7f92d0f38e0edd6c7b560a5d to your computer and use it in GitHub Desktop.
Save hidao80/4136e4bd7f92d0f38e0edd6c7b560a5d to your computer and use it in GitHub Desktop.
Qiitadon で投稿があったとき、トーストで通知するブックマークレット
(()=>{
let old_id = document.getElementsByClassName("item-list")[2].firstElementChild.dataset.id;
const timer = setInterval(() => {
let new_id = document.getElementsByClassName("item-list")[2].firstElementChild.dataset.id;
if (old_id !== new_id) {
old_id = new_id;
const parentElm = [...document.querySelectorAll('.column-header')].find(v => /ローカルタイムライン/.test(v.textContent)).parentElement.parentElement;
new Notification(parentElm.querySelector(".display-name__html").textContent, { body: parentElm.querySelector('.status__content')?.textContent ?? '', icon: parentElm.querySelector('.account__avatar, account__avatar-overlay-base')?.style?.backgroundImage?.replace(/^url\("|"\)/g, '') ?? ''});
}
},1000);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment