bzzhr Link Resolver

remove bzzhr's ad link

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name           bzzhr Link Resolver
// @name:ko        bzzhr 링크 변환기
// @namespace      BZZHR_RESOLVER_V1
// @run-at         document-end
// @version        1.0
// @description    remove bzzhr's ad link
// @description:ko bzzhr의 광고 링크를 제거하고 다운로드 링크를 바로 뱉어내도록 합니다.
// @author         Laria
// @match          https://bzzhr.co/f/*
// @icon           https://www.google.com/s2/favicons?sz=64&domain=bzzhr.co
// @license        MIT
// @encoding       utf-8
// ==/UserScript==

/*
 * == Change log ==
 * 1.0 - release
 */

const delay = ms => new Promise(resolve => setTimeout(resolve, ms));

//https://stackoverflow.com/questions/5525071
function waitForElm(selector) {
    return new Promise(resolve => {
        if (document.querySelector(selector)) {
            return resolve(document.querySelector(selector));
        }

        const observer = new MutationObserver(mutations => {
            if (document.querySelector(selector)) {
                observer.disconnect();
                resolve(document.querySelector(selector));
            }
        });

        // If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
        observer.observe(document.body, {
            childList: true,
            subtree: true
        });
    });
}

async function linkShow() {
  //remove countdown btn
  document.getElementById('countdown').classList.add("hidden");
  //show all link
  for (let link of document.getElementsByClassName("dl")) link.classList.remove("hidden");

  //repeat all link to resolve original download link
  document.querySelector('div.dl').querySelectorAll('a').forEach((i) => {
    if (i.getAttribute('data-href')) {
        i.innerText = i.innerText + ' ®';
        i.href = i.getAttribute('data-href');
    }
  });
}

async function rootProcedure(){
  'use strict';
  //wait link available
  await waitForElm('div.dl');
  await linkShow();
}

window.addEventListener('load', () => setTimeout(rootProcedure, 100));