Skip to content

Instantly share code, notes, and snippets.

@rongself
Last active November 3, 2020 21:58
Show Gist options
  • Save rongself/288ad6c887ffb184b469ae0295acc642 to your computer and use it in GitHub Desktop.
Save rongself/288ad6c887ffb184b469ae0295acc642 to your computer and use it in GitHub Desktop.
iitc script for multi passcode apply (点击下面raw按钮安装)
// ==UserScript==
// @id iitc-plugin-multi-passcode@rongself
// @name IITC plugin: multi passcode apply
// @category Controls
// @version 0.1.0.20150917.154202
// @namespace https://gist.github.com/rongself/288ad6c887ffb184b469ae0295acc642
// @updateURL https://gist.github.com/rongself/288ad6c887ffb184b469ae0295acc642
// @downloadURL https://gist.github.com/rongself/288ad6c887ffb184b469ae0295acc642
// @description [rongself-2016-07-17-154202] script for multi passcode apply
// @include https://www.ingress.com/intel*
// @include http://www.ingress.com/intel*
// @match https://www.ingress.com/intel*
// @match http://www.ingress.com/intel*
// @include https://www.ingress.com/mission/*
// @include http://www.ingress.com/mission/*
// @match https://www.ingress.com/mission/*
// @match http://www.ingress.com/mission/*
// @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() {};
//PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!!
//(leaving them in place might break the 'About IITC' page or break update checks)
plugin_info.buildName = 'rongself';
plugin_info.dateTimeVersion = '20160717.154202';
plugin_info.pluginId = 'multi-passcode';
//END PLUGIN AUTHORS NOTE
// PLUGIN START ////////////////////////////////////////////////////////
// use own namespace for plugin
window.plugin.multiPasscode = function() {};
window.plugin.multiPasscode.setup = function() {
$("#redeem").off('keypress');
$("#redeem").keypress(function(e) {
if((e.keyCode ? e.keyCode : e.which) !== 13) return;
var passcodes = $(this).val();
var timeTowait = 5000;
var start = 0;
if(!passcodes) return;
passcodes = passcodes.split(' ');
for(var index in passcodes){
setTimeout(function(){
var passcode = passcodes[index];
var jqXHR = window.postAjax('redeemReward', {passcode:passcode}, window.handleRedeemResponse, function(response) {
var extra = '';
if(response.status) {
extra = (window.REDEEM_STATUSES[response.status] || 'The server indicated an error.') + ' (HTTP ' + response.status + ')';
} else {
extra = 'No status code was returned.';
}
dialog({
title: 'Request failed: ' + data.passcode,
html: '<strong>The HTTP request failed.</strong> ' + extra
});
});
jqXHR.passcode = passcode;
},start);
start += timeTowait;
}
});
};
var setup = window.plugin.multiPasscode.setup;
// 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);
@MysticMagican
Copy link

Got it listed in my plugins (mobile), but now to use it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment