Komalis / InterpalsScript

// ==UserScript==
// @name InterpalsScript
// @description Visit each profile on the online page easily
// @author Osmond
// @match https://www.interpals.net/app/online*
// @run-at document-end
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @version 1.0.3
// ==/UserScript==

var visited_count = 0;

function visit()
{
	if(localStorage.getItem("init") != "true")
	{
		localStorage.setItem("visited", "[]");
		localStorage.setItem("init", "true");
	}
	var visited = JSON.parse(localStorage.getItem("visited"));
	var count = 0;
	$(".online_prof").each(function(i, e)
	{
		var href = $("a", e)[0].href;
		var pseudonyme = href.split("/")[3];
		if($.inArray(pseudonyme, visited) == -1)
		{
			setTimeout(function(){
				$.get(href)
				.done(function()
				{
					console.log(pseudonyme + " profile visited with success!");
					visited.push(pseudonyme);
					console.log(pseudonyme + " added to visited list!");
					localStorage.setItem("visited", JSON.stringify(visited));
				})
				.fail(function()
				{
					console.log(pseudonyme + " not visited because of an unknown issue...");
				})
				.always(function()
				{
					visited_count++;
					$("#count").html(visited_count);
				});
			}, count);
		}
		else
		{
			console.log(pseudonyme + " already visited!");
			visited_count++;
			$("#count").html(visited_count);
		}
		count += 1000;
	});	
}

$("input[value = 'Filter']").parent().append('<input type="button" value="Script">');
$("input[value = 'Filter']").parent().append('<span><span id="count">0</span> / ' + $(".online_prof").length + '</span>');

$("input[value = 'Script']").click(visit);