freezoo / Tinder MyMatches

// ==UserScript==
// @namespace     https://openuserjs.org/users/freezoo
// @name          Tinder MyMatches
// @description   Shows the images of people who liked you on Tinder.
// @version       1.2.0
// @include       https://tinder.com/*
// @grant         none
// @license       MIT
// ==/UserScript==

// ==OpenUserJS==
// @author freezoo
// copyright     2019, freezoo (https://openuserjs.org/users/freezoo)
// ==/OpenUserJS==

var IT;
var Matches;
var gm_date = 0;
var resp_date = 0;
function getMatch() {
    'use strict';
    gm_date = Date.now();
    fetch('https://api.gotinder.com/v2/fast-match/teasers', {
        mode: 'cors',
        credentials: 'include',
        headers: new Headers({
            'X-Auth-Token': localStorage.getItem('TinderWeb/APIToken'),
            'app-version': 1020359,
            'platform': 'app',
            'accept' : 'application/json',
            'x-supported-image-formats': 'jpeg',
        })
    })
    .then(res => Promise.all([res, res.json()]))
    .then(([res, data]) => {
        resp_date = Date.now();
        if (!data || !data.data || !data.data.results)
              return;
//        console.log(data);
        if (!Matches)
          	return Matches = data.data.results;
		data.data.results.reverse();
        var nl = 0;
        var knownIds = Matches.map(x => x.user._id);
        data.data.results.map(x => x.user._id).forEach(function(x, i){
          	if (!knownIds.includes(x)) {
		            nl++;
				        Matches.unshift(data.data.results[i]);
            }
        });
        if (nl > 0 && Notification)
	          new Notification('Tinder', {icon: 'https://tinder.com/favicon-32x32.png', body: 'You have ' + nl + ' new like' + (nl > 1 ? 's' : '') + '!'});
    });
}
getMatch();
IT = setInterval(getMatch,60000);

function imgSetter(){
  function inhib_go_gold(){
    document.querySelector('#modal-manager').style.display = "none";
    var buttons = document.querySelectorAll('#modal-manager button');
    if (buttons.length)
      buttons[buttons.length-1].click();
  }
  if (!(["https://tinder.com/app/likes-you", "https://tinder.com/app/gold-home"].includes(location.href))) {
		document.querySelectorAll('div[class*="Blur(8px)::a"]').forEach(function(x){
	    x.className = x.className.replace("Blur(8px)", '');
	  });  
    document.querySelector('#modal-manager').style.display = "";
    return;
  }
  if (!Matches || !Matches.length)
    return;

  var pics = document.querySelectorAll('div[class*="Blur(12px)::a"]');
	pics.forEach(function(x){
    x.className = x.className.replace('Blur(12px)::a', 'unblured')
  });

  if (!pics.length) {
    var containers = document.querySelectorAll('div.enterAnimationContainer div.StretchedBox');
    if (!containers.length || !containers[0].style.backgroundImage)
        return;
    inhib_go_gold();
    containers.forEach(function(x, i){
      x.style.backgroundImage = 'url("' + Matches[i].user.photos[0].url + '")';
    });
		return;
  }
  if (pics[0].style.backgroundImage)
  inhib_go_gold();
}
imgSetter();
setInterval(imgSetter, 1000);