Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var IDarray, tabArray, tempArray = new Array(); //Initialize arrays
- //Configure these:
- var target = "https://insertYourSubDomain.atlassian.net/secure/admin/user/AddUser!default.jspa";
- IDarray = "First Last,firstlast@example.com;Second Guy,second@example.com".split(';');
- var closeComplete = false; // Close tabs after submitting and logging
- var submit = true; // Press the submit button (no spot check)
- //don't change these
- var n = "\n";
- var i, test, macro;
- var failed = 0;
- var done = 0;
- var userName, fullName, emailAddress;
- var debugMe = false;
- function advance() {
- if (debugMe) {
- if (!window.confirm('Advancing. i=' + i + ', tab=' + (gBrowser.tabContainer.selectedIndex + 1) + '/' + gBrowser.browsers.length)) {
- iimExit();
- }
- }
- gBrowser.tabContainer.advanceSelectedTab(1, true); //advance tab
- }
- function log(errorCode, data) //Write URL to file, then close tab if log successful
- {
- data = data.replace(/ /g, "<sp>"); //Replace all occurrences of <space> because imacros doesn't like it
- test = '';
- if (errorCode != 1) // If doesn't equal 1 (no error) then log as failed, else log as succeeded.
- {
- macro = "CODE:ADD !EXTRACT {{!URLCURRENT}}" + n;
- macro += "ADD !EXTRACT " + errorCode + n;
- macro += "ADD !EXTRACT " + data + n;
- macro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=Failed.csv";
- if (debugMe) {
- if (!window.confirm(macro)) {
- iimExit();
- }
- }
- test = iimPlay(macro);
- failed++;
- } else {
- macro = "CODE:ADD !EXTRACT {{!URLCURRENT}}" + n;
- macro += "ADD !EXTRACT " + errorCode + n;
- macro += "ADD !EXTRACT " + data + n;
- macro += "SAVEAS TYPE=EXTRACT FOLDER=* FILE=Success.csv";
- if (debugMe) {
- if (!window.confirm(macro)) {
- iimExit();
- }
- }
- test = iimPlay(macro);
- done++;
- }
- if (test == 1) //if log succeeded
- {
- if (debugMe) {
- if (!window.confirm('Closing='+closeComplete+', i=' + i + '; errorCode=' + errorCode + '; tab=' + (gBrowser.tabContainer.selectedIndex + 1) + '/' + gBrowser.browsers.length)) {
- iimExit();
- }
- }
- if (closeComplete) {
- gBrowser.removeCurrentTab();
- } // Close tab.
- } else {
- iimDisplay('Log Failed: ' + iimGetLastError());
- }
- }
- for (i = 0; i < IDarray.length; i++) // Go through every ID in array
- {
- tempArray = IDarray[i].split(','); // Split new user into temporary array.
- userName = tempArray[1].split('@')[0].toString().toLowerCase(); // Do crazy string splitting madness
- fullName = tempArray[0];
- emailAddress = tempArray[1];
- if (debugMe) {
- window.alert(userName + ',' + fullName + ',' + emailAddress);
- }
- gBrowser.addTab(target + '?username=' + userName + '&fullname=' + fullName + '&email=' + emailAddress); //Open link with specified information
- if (i > 0) {
- advance();
- }
- if (i == 0) {
- gBrowser.removeCurrentTab(); //Close the first tab.
- }
- if (submit) {
- iimPlay('CODE:TAG POS=1 TYPE=INPUT:SUBMIT FORM=ID:user-create ATTR=ID:user-create-submit')
- }
- if (window.content.document.getElementById('user-create-username-error')) {
- log(0, (userName + ',' + fullName + ',' + emailAddress));
- } else {
- log(1, (userName + ',' + fullName + ',' + emailAddress));
- }
- }
- window.alert('Done.' + n + n + 'Total: ' + IDarray.length + n + 'Failed: ' + failed + n + 'Success: ' + done);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement