Last active
January 22, 2022 04:11
-
-
Save ozero/8f1c457048875e0d9e8622ed6037b316 to your computer and use it in GitHub Desktop.
IITC plugin: Post comm in multi-line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @id iitc-plugin-post-comm-multiline | |
// @name IITC plugin: Post comm in multiline | |
// @category Misc | |
// @version 0.2.0.20220122.02 | |
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion | |
// @updateURL none | |
// @downloadURL none | |
// @description Post comm in multiline | |
// @include https://*.ingress.com/* | |
// @include http://*.ingress.com/* | |
// @match https://*.ingress.com/* | |
// @match http://*.ingress.com/* | |
// @include https://*.ingress.com/mission/* | |
// @include http://*.ingress.com/mission/* | |
// @match https://*.ingress.com/mission/* | |
// @match http://*.ingress.com/mission/* | |
// @grant none | |
// ==/UserScript== | |
/* | |
https://gist.github.com/ozero/8f1c457048875e0d9e8622ed6037b316 | |
*/ | |
function wrapper(plugin_info) { | |
// ensure plugin framework is there, even if iitc is not yet loaded | |
if (typeof window.plugin !== 'function') window.plugin = function () { }; | |
// PLUGIN START //////////////////////////////////////////////////////// | |
// use own namespace for plugin | |
window.plugin.postCommMl = { | |
//setting dialog | |
openDialog: function(data){ | |
var html = '<div><textarea id="tx_postcommML" tabindex="0" style="width:380px;height:10em;' | |
+ 'color:black;background-color:white;margin-bottom:2px;" >' | |
+ '</textarea></div>' | |
+ '<button id="bt_postcommML" onclick="window.plugin.postCommMl.postMsg()">Post</button>'; | |
dialog({ | |
html: html, | |
id: 'plugin-post-comm-ml-dialog', | |
dialogClass: 'ui-post-comm-ml-dialog', | |
title: 'Input multiline comm (Faction)', | |
width:400, | |
closeText: "X" | |
}); | |
}, | |
postMsg: function() { | |
// | |
$("#bt_postcommML").prop("disabled", true); | |
$("#bt_postcommML").text("( Posting..... )"); | |
// | |
var c = "faction"; | |
//var c = "all"; | |
var latlng = map.getCenter(); | |
var msg = $("#tx_postcommML").val(); | |
var data = {message: msg, | |
latE6: Math.round(latlng.lat*1E6), | |
lngE6: Math.round(latlng.lng*1E6), | |
tab: c}; | |
var errMsg = 'Your message could not be delivered. You can copy&' + | |
'paste it here and try again if you want:\n\n' + msg; | |
window.postAjax('sendPlext', data, | |
//success | |
function(response) { | |
console.log(["success", response]); | |
if(response.error){ | |
alert(errMsg); | |
} | |
setTimeout(function(){ | |
$("#bt_postcommML").text("( Done. Reload to check comm. )"); | |
}, 1000) | |
}, | |
//fail | |
function(response) { | |
console.log(["error", response]); | |
alert(errMsg); | |
} | |
); | |
$('#chatinput input').val(''); | |
} | |
}; | |
// boot //////////////////////////// | |
var setup = function () { | |
$('#toolbox').append('<a onclick="window.plugin.postCommMl.openDialog();return false;">MLCOMM</a>'); | |
}; | |
// 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); |
Author
ozero
commented
Sep 5, 2016
•
- IntelMap accepts comm with line-breaks (multi-line).
- Ingress App displays line break properly.
- IntelMap(Stock) ignores line break in comm.
- IITC ignores line break in comm too.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment