aldebaran / Tynker minecraft QR code

// ==UserScript==
// @copyright 2019, aldebaran (https://openuserjs.org//users/aldebaran)
// @name         Tynker minecraft QR code
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  Helper script to create QR code to help download resource pak
// @author       aldebaran
// @match        https://www.tynker.com/minecraft/editor/*
// @license MIT
// @require http://code.jquery.com/jquery-latest.js
// @require https://raw.githubusercontent.com/jeromeetienne/jquery-qrcode/master/jquery.qrcode.min.js
// ==/UserScript==

// https://gist.github.com/chrisjhoughton/7890303
function waitForEl(selector, callback, maxtries = false, interval = 100) {
  const poller = setInterval(() => {
    const el = jQuery(selector)
    const retry = maxtries === false || maxtries-- > 0
    if (retry && el.length < 1) return // will try again
    clearInterval(poller)
    callback(el || null)
  }, interval)
}

function createQRCode(el) {
  el.before("<div id='qrcode'></div>");
  jQuery('#qrcode').qrcode({
    width: 128,
    height: 128,
    text: el.html()
  });
}

(function () {
  'use strict';
  $(document).ready(function () {
    debugger;
    waitForEl("div.code.ng-binding", createQRCode);
  });
})();