bzzhr Link Resolver

remove bzzhr's ad link

  1. // ==UserScript==
  2. // @name bzzhr Link Resolver
  3. // @name:ko bzzhr 링크 변환기
  4. // @namespace BZZHR_RESOLVER_V1
  5. // @run-at document-end
  6. // @version 1.0
  7. // @description remove bzzhr's ad link
  8. // @description:ko bzzhr의 광고 링크를 제거하고 다운로드 링크를 바로 뱉어내도록 합니다.
  9. // @author Laria
  10. // @match https://bzzhr.co/f/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=bzzhr.co
  12. // @license MIT
  13. // @encoding utf-8
  14. // ==/UserScript==
  15.  
  16. /*
  17. * == Change log ==
  18. * 1.0 - release
  19. */
  20.  
  21. const delay = ms => new Promise(resolve => setTimeout(resolve, ms));
  22.  
  23. //https://stackoverflow.com/questions/5525071
  24. function waitForElm(selector) {
  25. return new Promise(resolve => {
  26. if (document.querySelector(selector)) {
  27. return resolve(document.querySelector(selector));
  28. }
  29.  
  30. const observer = new MutationObserver(mutations => {
  31. if (document.querySelector(selector)) {
  32. observer.disconnect();
  33. resolve(document.querySelector(selector));
  34. }
  35. });
  36.  
  37. // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
  38. observer.observe(document.body, {
  39. childList: true,
  40. subtree: true
  41. });
  42. });
  43. }
  44.  
  45. async function linkShow() {
  46. //remove countdown btn
  47. document.getElementById('countdown').classList.add("hidden");
  48. //show all link
  49. for (let link of document.getElementsByClassName("dl")) link.classList.remove("hidden");
  50.  
  51. //repeat all link to resolve original download link
  52. document.querySelector('div.dl').querySelectorAll('a').forEach((i) => {
  53. if (i.getAttribute('data-href')) {
  54. i.innerText = i.innerText + ' ®';
  55. i.href = i.getAttribute('data-href');
  56. }
  57. });
  58. }
  59.  
  60. async function rootProcedure(){
  61. 'use strict';
  62. //wait link available
  63. await waitForElm('div.dl');
  64. await linkShow();
  65. }
  66.  
  67. window.addEventListener('load', () => setTimeout(rootProcedure, 100));