Advertisement
Guest User

kurwaaaaaaa

a guest
Apr 8th, 2020
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Notification.requestPermission();
  2. const strip = (html) => {
  3.     let doc = new DOMParser().parseFromString(html.replace(/<br>/gi, '\n'), 'text/html');
  4.     return doc.body.textContent || "";
  5. }
  6.  
  7. let thisTab = 0, active = 1;
  8. let bc = new BroadcastChannel('superjavascript');
  9. bc.onmessage = ev => {
  10.     if (ev.data == "new tab") thisTab++;
  11.     else if (parseInt(ev.data) < thisTab) active = 0;
  12. }
  13. bc.postMessage('new tab');
  14.  
  15. const powiadomienie = (data) => {
  16.     if ((document.hasFocus() && (window.location.href.includes(data.threadId) || !/\d/.test(window.location.href))) || typeof curbs[data.boardId][data.threadId] !== "undefined") {
  17.         bc.postMessage("-1");
  18.         active = 0;
  19.     } else bc.postMessage(thisTab);
  20.     setTimeout(() => {
  21.         if (active) {
  22.             const img = typeof data.file !== "undefined" ? `https://wilchan.org/boards/${data.boardId}/thumb/${data.fileThumbName}` : "";
  23.             const text = strip(data.message);
  24.             let notification = new Notification('Kliknij, aby przejść do tematu', { body: text, image: img });
  25.             notification.onclick = (event) => {
  26.                 event.preventDefault();
  27.                 const win = window.open(`https://wilchan.org/${data.boardId}/thread/${data.threadId}#${data.postId}`, '_blank');
  28.                 win.focus();
  29.             }
  30.         }
  31.         active = 1;
  32.     }, 200)
  33. }
  34.  
  35. sseCreateFunctionArray.push(powiadomienie);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement