This repository was archived by the owner on Jan 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathspamfilter.user.js
68 lines (56 loc) · 2.62 KB
/
spamfilter.user.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
// ==UserScript==
// @id iitc-plugin-spam-filter@3ch01c
// @name IITC plugin: spam-filter
// @category Misc
// @version 0.0.7
// @namespace https://github.com/3ch01c/ingress-intel-total-conversion
// @description This is a spam filter plugin which filters out SPAM from Comm messages.
// @include https://*.ingress.com/intel*
// @include http://*.ingress.com/intel*
// @match https://*.ingress.com/intel*
// @match http://*.ingress.com/intel*
// @include https://*.ingress.com/mission/*
// @include http://*.ingress.com/mission/*
// @match https://*.ingress.com/mission/*
// @match http://*.ingress.com/mission/*
// @match https://intel.ingress.com/*
// @grant none
// @updateURL https://github.com/Eccenux/iitc-plugin-spam-filter/raw/master/spamfilter.meta.js
// @downloadURL https://github.com/Eccenux/iitc-plugin-spam-filter/raw/master/spamfilter.user.js
// ==/UserScript==
function wrapper(plugin_info) {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function() {};
// setup plugin
var setup = function() {
var renderData_orig = window.chat.renderData;
// spam filter
window.chat.renderData = function(data, element, likelyWereOldMsgs) {
var filteredData = {};
for (var key in data) {
var user = data[key][3];
if (user.search(/^(enl|res)[0-9]+$/)>=0) {
continue;
}
var text = data[key][2];
if (text.search(/xmps\.biz|ecwid\.com|ingress-(shop|store)|(store|shop)-ingress|ingressfarm\.com/i)>=0) {
continue;
}
filteredData[key] = data[key];
}
renderData_orig(filteredData, element, likelyWereOldMsgs);
}
}
//PLUGIN END //////////////////////////////////////////////////////////
setup.info = plugin_info; //add the script info data to the function as a property
if(!window.bootPlugins) window.bootPlugins = [];
window.bootPlugins.push(setup);
// if IITC has already booted, immediately run the 'setup' function
if(window.iitcLoaded && typeof setup === 'function') setup();
} // wrapper end
// inject code into site context
var script = document.createElement('script');
var info = {};
if (typeof GM_info !== 'undefined' && GM_info && GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');'));
(document.body || document.head || document.documentElement).appendChild(script);