<commit_before>// ==UserScript==
// @name        NemIdPlugin
// @include     *bwin.dk*
// @version     1.0.4
// @require     https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js
// @grant       none
// ==/UserScript==

var nemid = "606978237";
var password = "<PASSWORD>";

var containerDiv = $("<div/>", {
		style : "text-align:center"
	});

var credentialsInput = $("<input/>", {
		type : "text",
		readonly : "readonly",
		style : "display:block; margin:5px auto 0; opacity:1",
		value : nemid + "/" + password
	});

var otpCodeInput = $("<input/>", {
		id : "otp-code",
		type : "text",
		placeholder : "otp code",
		focus : function () {
			$(this).val("");
      $("#nemid-code").val("");
		},
		keyup : function () {
			var otp = $("#otp-code").val();
			var code = getNemIdCode(otp);
			$("#nemid-code").val(code);
		}
	});

var nemidCodeInput = $("<input/>", {
		id : "nemid-code",
		type : "text",
		placeholder : "nemid code",
		readonly : "readonly",
		style : "opacity:1"
	});

containerDiv.append(credentialsInput);
containerDiv.append(otpCodeInput);
containerDiv.append(nemidCodeInput);

$(".nemid-container .preheader").append(containerDiv);

function getNemIdCode(key) {
	var obj = localStorage.getItem(nemid);

	if (obj != null) {
		return JSON.parse(obj)[key]; ;
	}

	var storage = new Object();

	$.ajax({
		type : "GET",
		url : "https://cors-anywhere.herokuapp.com/https://appletk.danid.dk/developers/OtpCard?userid=" + nemid,
		dataType : "html",
		success : function (data) {
			var matches = data.match(/\<td align=\"center\"\>(\d{4}?)\<\/td\>\<td align=\"center\"\>(\d{6}?)\<\/td\>/g);

			for (i = 0; i < matches.length; i++) {
				var match = matches[i];
				var otp = match.match(/\d{4}/);
				var code = match.match(/\d{6}/);
				storage["" + otp + ""] = code;
			}
			localStorage.setItem(nemid, JSON.stringify(storage))
		}
	});

	return storage[key];<commit_msg>added async:false<commit_after>// ==UserScript==
// @name        NemIdPlugin
// @include     *bwin.dk*
// @version     1.0.4
// @require     https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.js
// @grant       none
// ==/UserScript==

var nemid = "606978237";
var password = "<PASSWORD>";

var containerDiv = $("<div/>", {
		style : "text-align:center"
	});

var credentialsInput = $("<input/>", {
		type : "text",
		readonly : "readonly",
		style : "display:block; margin:5px auto 0; opacity:1",
		value : nemid + "/" + password
	});

var otpCodeInput = $("<input/>", {
		id : "otp-code",
		type : "text",
		placeholder : "otp code",
		focus : function () {
			$(this).val("");
      $("#nemid-code").val("");
		},
		keyup : function () {
			var otp = $("#otp-code").val();
			var code = getNemIdCode(otp);
			$("#nemid-code").val(code);
		}
	});

var nemidCodeInput = $("<input/>", {
		id : "nemid-code",
		type : "text",
		placeholder : "nemid code",
		readonly : "readonly",
		style : "opacity:1"
	});

containerDiv.append(credentialsInput);
containerDiv.append(otpCodeInput);
containerDiv.append(nemidCodeInput);

$(".nemid-container .preheader").append(containerDiv);

function getNemIdCode(key) {
	var obj = localStorage.getItem(nemid);

	if (obj != null) {
		return JSON.parse(obj)[key]; ;
	}

	var storage = new Object();

	$.ajax({
		type : "GET",
		url : "https://cors-anywhere.herokuapp.com/https://appletk.danid.dk/developers/OtpCard?userid=" + nemid,
		dataType : "html",
		async: false,
		success : function (data) {
			var matches = data.match(/\<td align=\"center\"\>(\d{4}?)\<\/td\>\<td align=\"center\"\>(\d{6}?)\<\/td\>/g);

			for (i = 0; i < matches.length; i++) {
				var match = matches[i];
				var otp = match.match(/\d{4}/);
				var code = match.match(/\d{6}/);
				storage["" + otp + ""] = code;
			}
			localStorage.setItem(nemid, JSON.stringify(storage))
		}
	});

	return storage[key];
{'fraction_non_alphanumeric': 0.22399372713016205, 'fraction_numerical': 0.012545739675901725, 'mean_word_length': 3.2616926503340755, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4367555', 'n_tokens_mistral': 1561, 'n_tokens_neox': 1419, 'n_words': 270}