iredadmin_CSV_OneLineAdder

Allows simply add users by one CSV line in the iredadmin web interface

  1. // ==UserScript==
  2. // @name iredadmin_CSV_OneLineAdder
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Allows simply add users by one CSV line in the iredadmin web interface
  6. // @author Djamana
  7. // @match https://*/iredadmin/create/user/*
  8. // @match https://*/iredadmin/profile/user/general/*?msg=*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15.  
  16. function timerCB(callback) {
  17. //debugger
  18. //$('[name=confirmpw]')[0].value = $('[name=newpw]')[0].value
  19.  
  20. var Lines = $('[name=OneLineAdder]')[0].value.split(";")
  21. if (Lines.length == 3) {
  22.  
  23. $('[name=username]')[0].value = Lines[0]
  24.  
  25. $('[name=newpw]')[0].value = Lines[1]
  26. $('[name=confirmpw]')[0].value = Lines[1]
  27.  
  28. $('[name=cn]')[0].value = Lines[2]
  29. }
  30.  
  31. }
  32.  
  33. if (location.pathname.indexOf("/iredadmin/create/user/") != -1) {
  34. setInterval( timerCB, 500);
  35.  
  36. $('form')
  37. .append(
  38. $('<span>')
  39. .text ("CSV_OneLineAdder Ver 0.1 [Feb'19]")
  40. )
  41. .append(
  42. $('<input>')
  43. .attr('type', "text")
  44. .attr('name', "OneLineAdder")
  45. .attr('size', '65')
  46. .attr('class', "text fl-space")
  47. .attr('value', "")
  48. .attr('title', "Username;Password;DisplayName")
  49. );
  50.  
  51. $('[name=OneLineAdder]').focus();
  52. //Name;username;password
  53. /*
  54. .append(
  55. $('<input>')
  56. .attr('type', "text")
  57. .attr('name', "employeeNumber")
  58. .attr('size', '35')
  59. .attr('class', "text fl-space")
  60. .attr('value', "15")
  61. )
  62. */
  63. } else if ( location.search == "?msg=UPDATED") {
  64. //debugger
  65.  
  66.  
  67. location.search = "";
  68. location.pathname = "/iredadmin/create/user/";
  69.  
  70.  
  71. } else if ( location.search == "?msg=CREATED") {
  72. //debugger
  73. $('[name=employeeNumber]').focus();
  74. }
  75.  
  76.  
  77. })();
  78.  
  79. //======================================================================
  80.  
  81. // _ ____ _____ _ _ _
  82. // | | / __ \ |_ _| | | | || |
  83. // | || | | | _ _ ___ _ __ _ _ | | _ __ ___ | |_ __ _ | || |
  84. // _ | || | | || | | | / _ \| '__|| | | | | | | '_ \ / __|| __|/ _` || || |
  85. // | |__| || |__| || |_| || __/| | | |_| | _| |_ | | | |\__ \| |_| (_| || || |
  86. // \____/ \___\_\ \__,_| \___||_| \__, | |_____||_| |_||___/ \__|\__,_||_||_|
  87. // __/ |
  88. // |___/
  89. // from http://erikvold.com/blog/index.cfm/2010/6/14/using-jquery-with-a-user-script
  90.  
  91.  
  92. function addJQuery(callback) {
  93.  
  94. // create a new <_script> element and insert it into the document.body
  95. // 'callback' will be the body of the script
  96. /*
  97. var fn_scriptInject =
  98. function() {
  99. var script;
  100. script = document.createElement("script");
  101. script.textContent = "(" + callback.toString() + ")();";
  102. document.body.appendChild(script);
  103.  
  104. // $('<script>').text("(" + callback.toString() + ")();").appendTo('<body>')
  105.  
  106. };
  107. */
  108.  
  109. if (typeof $ !== 'undefined') {
  110. // jQuery is loaded
  111. //try {
  112.  
  113.  
  114. // console.log ('jQuery version ($):' + jQuery.fn.jquery)
  115. // Unload jQuery
  116. // debugger
  117. // jQuery.noConflict();
  118.  
  119. // console.log ('jQuery version after noConflict:' + jQuery.fn.jquery)
  120.  
  121. //} catch (e) {
  122. // }
  123. // $(fn_scriptInject);
  124. // $(callback);
  125.  
  126. } //else {
  127.  
  128. // jQuery is not loaded
  129. // optional TODO: check jQuery Version
  130. var script;
  131. script = document.createElement("script");
  132. ///resource.php/344161-344/jquery-1.7.2.min.js
  133. script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js");
  134. // script.setAttribute("src", "//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js");
  135. // script.setAttribute("src", "/resource.php/344161-344/jquery-1.7.2.min.js");
  136.  
  137. // script.addEventListener('load', fn_scriptInject, false);
  138. script.addEventListener('load', callback, false);
  139.  
  140. document.body.appendChild(script);
  141. //}
  142.  
  143. }
  144. //======================================================================