-
Notifications
You must be signed in to change notification settings - Fork 0
/
okcupgrade.js
73 lines (65 loc) · 2.59 KB
/
okcupgrade.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// ==UserScript==
// @name OkFilterIt
// @namespace
// @version 0.2
// @description take over someones world
// @author https://github.com/okyk
// @match https://www.okcupid.com/match
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @grant none
// ==/UserScript==
(function() {
'use strict';
var processed = processed || new Set();
var filtered = filtered || new Set();
var pending = pending || new Set();
const mustHave = new Array('straight', 'woman', 'single');
const block = new Array("black", "overweight", "full figured", "a little extra", "curvy", "queer", "trans", "transfeminine", "transgender", "transsexual", "nonconforming", "genderqueer", "pansexual", "demisexual", "questioning", "asexual", "heteroflexible", "gay", "lesbian", "bisexual", "homoflexible", "vegetarian", "vegan");
const cardMatcher=".match-results-card";
const cardProfileURL='.match-results-card';
const profileFilterMatcher='.matchprofile-details-text';
const starSelector='.match-info-liked'
function filterit(match, url) {
if(url==null){
return;
}
jQuery.get(url).done(function(data) {
processed.add(url);
pending.delete(url);
var plaintext = '';
var html=data.match(/var profileParams = [^\n]+/);
if(html==null){
console.log("UNR: "+url);
return;
}
var blockreason="";
var profile=jQuery.parseJSON(data.match(/var profileParams = [^\n]+/)[0].match(/{.*}/)[0]).profile;
profile.details.forEach(function(element){plaintext+=' '+element.text.text.toLowerCase()});
block.forEach(function(element){blockreason+=plaintext.includes(element)?"+"+element:"";});
mustHave.forEach(function(element){blockreason+=!plaintext.includes(element)?"-"+element+",":"";});
if(blockreason!=""){
match.style.display = "none";
console.log("Filtered: ["+blockreason+"] "+url);
filtered.add(url);
}
});
}
var filternonfit = function() {
var mills = 0;
jQuery(cardMatcher).each(function() {
if(this.style.display!=null && jQuery(jQuery(this).find(starSelector)).length!=0){
this.style.display = "none";
return;
}
var url = cardMatcher!=cardProfileURL?jQuery(jQuery(this).find(cardProfileURL)[0]).href:url = this.href;
if (filtered.has(url)) {
this.style.display = "none";
} else if (!processed.has(url) && !pending.has(url)) {
pending.add(url);
setTimeout(filterit(this, url), mills);
mills += 500;
}
});
};
setInterval(filternonfit, 300);
})();