// ==UserScript==
// @author DanielOnDiordna
// @name Filter Comms for MU and more
// @category Tweak
// @version 1.1.0.20231019.181300
// @updateURL https://raw.githubusercontent.com/IITC-CE/Community-plugins/master/dist/DanielOnDiordna/filter-comms.meta.js
// @downloadURL https://raw.githubusercontent.com/IITC-CE/Community-plugins/master/dist/DanielOnDiordna/filter-comms.user.js
// @description [danielondiordna-1.1.0.20231019.181300] Filter the 'all' comms pane, options to show only created Control Fields and their MUs, filter for capture, deploy, link, destroy or drone actions, filter faction or public chat, or filter all actions by faction
// @id filter-comms@DanielOnDiordna
// @namespace https://softspot.nl/ingress/
// @match https://intel.ingress.com/*
// @grant none
// ==/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() {};
// use own namespace for plugin
window.plugin.filtercomms = function() {};
var self = window.plugin.filtercomms;
self.id = 'filtercomms';
self.title = 'Filter Comms for MU and more';
self.version = '1.1.0.20231019.181300';
self.author = 'DanielOnDiordna';
self.changelog = `
Changelog:
version 1.1.0.20231019.181300
version 1.1.0.20231006.231600
version 1.1.0.20230925.232700
- version upgrade due to a change in the wrapper, added changelog
- updated for IITC version 0.36.1 and 0.37.0
- added faction machina
version 1.0.0.20230223.164800
- reversed changelog order to show latest first
- major release version 1.0.0
- renamed plugin from Filter Comms for MU, to Filter Comms for MU and more
- added a menu button to the 'all' comms pane
- added filter options for capture, deploy, link or destroy actions
- added a filter for fireworks and beacons
- added a filter for battle beacon announcements
- added a filter by faction
- added label double click to filter for only the selected filter
- added buttons to check or disable all checkboxes
version 0.0.3.20211024.003700
- minor change to work side by side with Logs Diary plugin by ZasoItems
version 0.0.2.20210724.002500
- prevent double plugin setup on hook iitcLoaded
version 0.0.2.20210421.190200
- minor fix for IITC CE where runHooks iitcLoaded is executed before addHook is defined in this plugin
version 0.0.2.20210126.231800
- updated plugin wrapper and userscript header formatting to match IITC-CE coding
- auto show toggle filter menu on mobile when 'all' pane is displayed
version 0.0.1.20201112.164400
- First version
`;
self.namespace = 'window.plugin.' + self.id + '.';
self.pluginname = 'plugin-' + self.id;
self.settings = {
fields: true,
capture: true,
deploy: true,
link: true,
destroyedresonator: true,
destroyedlink: true,
destroyedfield: true,
drone: true,
beacon: true,
battlebeacon: true,
firstcapture: true,
yourportalattack: true,
yourportalneutralized: true,
yourlinkdestroyed: true,
yourkinetic: true,
faction: true,
public: true,
enl: true,
res: true,
mac: true
};
self.updatechat = function() {
let tab = window.chat.getActive();
switch(tab) {
case 'faction':
window.chat.renderFaction(false);
break;
case 'all':
window.chat.renderPublic(false);
break;
case 'alerts':
window.chat.renderAlerts(false);
break;
case 'public':
window.chat.renderPublicChat(false);
break;
}
};
self.hidemessage = function(msg) {
// msg comes from the window.chat.renderData
// if ((/color:#03DC03/.test(msg[2]))) console.log(msg);
// console.log(msg[2]);
if (!self.settings.fields && (/ created a Control Field/.test(msg[2]))) return true;
if (!self.settings.capture && (/> captured/.test(msg[2]))) return true;
if (!self.settings.deploy && (/> deployed a Resonator/.test(msg[2]))) return true;
if (!self.settings.link && (/ linked from/.test(msg[2]))) return true;
if (!self.settings.destroyedresonator && (/> destroyed a Resonator/.test(msg[2]))) return true;
if (!self.settings.destroyedlink && (/> destroyed the Link|destroyed the (FACTION.*?>|) Link/.test(msg[2]))) return true;
if (!self.settings.destroyedfield && (/> destroyed a Control Field|destroyed the (FACTION.*?>|) Control Field/.test(msg[2]))) return true;
if (!self.settings.drone && (/>Drone returned/.test(msg[2]))) return true;
if (!self.settings.battlebeacon && (/ won a CAT-I Rare Battle Beacon on |Rare Battle Beacon will be deployed at the end of the Septicycle/.test(msg[2]))) return true;
if (!self.settings.beacon && (/deployed a Beacon on/.test(msg[2]))) return true;
if (!self.settings.firstcapture && (/ captured their first Portal/.test(msg[2]))) return true;
if (!self.settings.yourportalattack && (/Your Portal.*?is under attack/.test(msg[2]))) return true;
if (!self.settings.yourportalneutralized && (/Your Portal.*neutralized by/.test(msg[2]))) return true;
if (!self.settings.yourlinkdestroyed && (/Your Link.*destroyed by/.test(msg[2]))) return true;
if (!self.settings.yourkinetic && (/Your Kinetic Capsule/.test(msg[2]))) return true;
let el = document.createElement('table');
el.innerHTML = msg[2];
if (!self.settings.faction && (/>\[faction\]\[public\]This plugin adds a filter button to the chat panes.
You can set a filter for the 'all' comms pane.
Filter the 'all' comms pane, options to show only created Control Fields and their MUs, filter for capture, deploy, link, destroy or drone actions, filter faction or public chat, or filter by faction.
Double click a checkbox or the label to disable all other checkboxes and keep only one checked.
On mobile devices, the dialog will be aligned at the top and will auto show/hide with the All chat pane. Close button will minimize the dialog; the title bar toggles minimize.
All filters will be reset after a page reload; settings are not stored.
Be aware that filter by faction will overrule all other filters.