View difference between Paste ID: uu34GgUy and V4CG49f6
SHOW: | | - or go back to the newest paste.
1-
function INSERT_OR_REMOVE(table, id) {
1+
function INSERT_OR_REMOVE(table, id, callAfter) {
2
    if (isNaN(id))
3
        return;
4
5
    var parsed = parseInt(id);
6
    
7
    chrome.storage.local.get(table, function (data) {
8
        if (data[table] == null)
9
            data[table] = [];
10
11
        if (!data[table].includes(id))
12
            data[table].push(id);
13
        else
14
            data[table].remByVal(id);
15
16
        chrome.storage.local.set(data);
17
		if (callAfter) {
18
			callAfter(data);
19
		}
20
    });
21
}
22-
		var buttons = $("div.base-btn").closest("table");
22+
23-
		for (i = 0; i < buttons.length; i++) { 
23+
24-
			var id = $(buttons[i]).attr("data-id");
24+
25-
			
25+
		colorizeData(data);
26-
			if (data["blocked"].includes(id))
26+
27-
				$(buttons[i]).parent().addClass('blocked');
27+
28-
			else
28+
29-
				$(buttons[i]).parent().removeClass('blocked');
29+
30
function colorizeData(data) {
31
	var buttons = $("div.base-btn").closest("table");
32-
}
32+
	for (i = 0; i < buttons.length; i++) { 
33
		var id = $(buttons[i]).attr("data-id");
34
	
35
		if (data["blocked"].includes(id))
36
			$(buttons[i]).parent().addClass('blocked');
37
		else
38
			$(buttons[i]).parent().removeClass('blocked');
39
	}
40
}
41
42
//INSERT_OR_REMOVE("blocked", 12, colorizeData);