Lightsaber Escape QR Code Display

Adds a QR Code of the "lightsaber URL" to the front page of Lightsaber Escape

اعتبارا من 24-03-2016. شاهد أحدث إصدار.

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 or Violentmonkey 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.

ستحتاج إلى تثبيت إضافة مثل Stylus لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتتمكن من تثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

ستحتاج إلى تثبيت إضافة لإدارة أنماط المستخدم لتثبيت هذا النمط.

(لدي بالفعل مثبت أنماط للمستخدم، دعني أقم بتثبيته!)

// ==UserScript==
// @name          Lightsaber Escape QR Code Display
// @namespace     DoomTay
// @description   Adds a QR Code of the "lightsaber URL" to the front page of Lightsaber Escape
// @version       1.1.0
// @include       https://lightsaber.withgoogle.com/
// @grant         GM_xmlhttpRequest

// ==/UserScript==

var observer = new MutationObserver(function(mutations) {
	mutations.forEach(function(mutation) {
        if(document.getElementById("url") && document.getElementById("url").textContent.indexOf("g.co") > -1)
        {
            observer.disconnect();
            lightsaberURL = document.getElementById("url");
            GM_xmlhttpRequest({
                method: "GET",
                url: "https://chart.googleapis.com/chart?chs=120x120&cht=qr&chl=" + lightsaberURL.textContent + "&chld=L|1&choe=UTF-8",
                overrideMimeType: "text/plain; charset=x-user-defined",
                onload: function(response) {
                    var QRCode = new Image();
                    QRCode.id = "LSCode";
                    var arr = new Uint8Array(response.responseText.length);
                    
                    for(var i = 0; i < response.responseText.length; ++i) {
                        arr[i] = response.responseText.charCodeAt(i) & 0xFF;
                    }
                    
                    var imageData = new Blob([arr.buffer],{type:"image/png"});
                    QRCode.src = window.URL.createObjectURL(imageData);
                    document.getElementsByClassName("centered")[0].insertBefore(QRCode,document.getElementsByClassName("connection-url-wrapper style-scope sw-page-landing")[0]);
                    QRCode.width = 120;
                    QRCode.height = 120;
                    QRCode.style.position = "absolute";
                    QRCode.style.left = "45%";
                    QRCode.style.bottom = "-35px";
                }
            });
        }
	});    
});
var config = { attributes: true, childList: true, characterData: true, subtree: true };
observer.observe(document.body, config);