smskcntr Script v4

simsekcountr

目前为 2018-03-14 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name smskcntr Script v4
  3. // @description simsekcountr
  4. // @include http://www.erepublik.com/*
  5. // @include http://ww*.erepublik.com/*
  6. // @include https://ww*.erepublik.com/*
  7. // @include http://erepublik.com/*
  8. // @include https://erepublik.com/*
  9. // @include https://*.erepublik.com/*
  10. // @include http://www.erepublik.com/*
  11. // @include https://www.erepublik.com/*/military/battlefield-new/*
  12. // @exclude http://www.erepublik.com/TTE
  13. // @version 5.1
  14. // @license LGPL http://www.gnu.org/licenses/lgpl.html
  15. // @namespace https://greasyfork.org/users/29736
  16. // ==/UserScript==
  17. function addJQuery(callback) {
  18. var script = document.createElement('script');
  19. script.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js');
  20. script.addEventListener('load', function () {
  21. var script = document.createElement('script');
  22. script.textContent = 'window.jQ=jQuery.noConflict(true);(' + callback.toString() + ')();';
  23. document.body.appendChild(script);
  24. }, false);
  25. document.body.appendChild(script);
  26. }
  27. addJQuery(function () {
  28. jQ(document).ready(function () {
  29. var battle_listing = jQ('#content div.rest').eq(0);
  30. var baseUrl = 'https://www.simsekblog.com/';
  31. battle_listing.prepend('<div style="width:330px;height:10px;">' +
  32. '<iframe scrolling="no" style="border:0;width:100%;height:100%;" src="' + baseUrl + '"></iframe>' +
  33. '</div>'
  34. );
  35. var img = new Image();
  36. img.src = baseUrl + '/log?' + jQ.param({
  37. citizenId: ErpkPvp.citizenId,
  38. remainingFood: food_remaining,
  39. currentEnergy: globalNS.userInfo.wellness
  40. });
  41. });
  42. });
  43. var urlList = new Array();
  44. function add(name, url, target)
  45. {
  46. var item = {
  47. 0: name,
  48. 1: url,
  49. 2: target
  50. };
  51. urlList.push(item);
  52. }
  53. function update()
  54. {
  55. var ul = document.getElementById('menu5').getElementsByTagName('ul') [0];
  56. for (var i = 0; i < urlList.length; i++)
  57. {
  58. var li = document.createElement('li');
  59. var link = document.createElement('a');
  60. link.setAttribute('href', urlList[i][1]);
  61. link.setAttribute('target', ((urlList[i][2] == true) ? '_blank' : '_self'));
  62. var name = document.createTextNode(urlList[i][0]);
  63. link.appendChild(name);
  64. li.appendChild(link);
  65. ul.appendChild(li);
  66. }
  67. }
  68. add('IRC', 'https://discordapp.com/channels/305021604575051777/305022161549131787', true);
  69. add('smskcntr site', 'https://smskcntr.blogspot.com.tr/', true);
  70. add('EA Gazetesi', 'https://www.erepublik.com/en/newspaper/ea-gazetesi-236231/1', true);
  71. update();
  72. (function () {
  73. var clickEvent = document.createEvent('MouseEvent');
  74. clickEvent.initEvent('click', true, true);
  75. document.addEventListener('keydown', function (e) {
  76. switch (e.keyCode)
  77. {
  78. case 70: //F
  79. var a = document.getElementById('fight_btn');
  80. a.dispatchEvent(clickEvent);
  81. return false;
  82. break;
  83. case 65: //A
  84. var a = document.getElementById('add_damage_btn');
  85. a.dispatchEvent(clickEvent);
  86. return false;
  87. break;
  88. case 83: //S
  89. var a = document.getElementById('weapon_btn');
  90. a.dispatchEvent(clickEvent);
  91. return false;
  92. break;
  93. case 69: //E
  94. var a = document.getElementsByClassName('food_btn') [0];
  95. a.dispatchEvent(clickEvent);
  96. return false;
  97. break;
  98. case 87: //W
  99. var a = document.getElementById('AutoBotSwitch');
  100. a.dispatchEvent(clickEvent);
  101. return false;
  102. break;
  103. }
  104. },
  105. false);
  106. }) ();
  107. function addJQuery(callback) {
  108. var script = document.createElement('script');
  109. script.setAttribute('src', '//ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js');
  110. script.addEventListener('load', function () {
  111. var script = document.createElement('script');
  112. script.textContent = 'window.jQ=jQuery.noConflict(true);(' + callback.toString() + ')();';
  113. document.body.appendChild(script);
  114. }, false);
  115. document.body.appendChild(script);
  116. }
  117. addJQuery(function () {
  118. jQ(document).ready(function () {
  119. /** PREPARE DATA **/
  120. var listings = jQ('div.area.employees > div.listing_holder > div.list_group > div.listing');
  121. var rows = [
  122. ];
  123. listings.each(function (index, e) {
  124. var id = jQ(e).find('div.employee_info > a.remove').attr('id');
  125. var row = {
  126. citizenId: parseInt(id.substr(id.lastIndexOf('_') + 1), 10),
  127. citizenName: jQ(e).find('div.employee_info > a.employee_entry > strong').html(),
  128. salary: parseFloat(jQ(e).find('div.employee_salary > input.old_salary_value').val()).toString().replace('.', ',')
  129. };
  130. var day = 1;
  131. jQ(e).find('div.employee_presence > div.working_days > span').each(function (index, e) {
  132. var status;
  133. if (jQ(e).hasClass('worked')) {
  134. status = 1;
  135. } else if (jQ(e).hasClass('nan')) {
  136. status = null
  137. } else {
  138. status = 0;
  139. }
  140. row['day' + day] = status;
  141. day++;
  142. });
  143. rows.push(row);
  144. });
  145. /** CONVERT TO TSV **/
  146. var glue = '\t';
  147. var tsv = [
  148. ];
  149. var line;
  150. var first = true;
  151. for (var i in rows) {
  152. if (first) {
  153. line = [
  154. ];
  155. for (var key in rows[i]) {
  156. line.push(key);
  157. }
  158. tsv.push(line.join(glue));
  159. first = false;
  160. }
  161. line = [
  162. ];
  163. for (var key in rows[i]) {
  164. line.push(rows[i][key]);
  165. }
  166. tsv.push(line.join(glue));
  167. }
  168. tsv = tsv.join('\n');
  169. jQ('div.area.employees > h4').after('<textarea readonly="readonly" id="textarea-export-employees" onfocus="this.select()" onMouseUp="return false" style="font-size: 11px;font-family:consolas, monospace;width:100%;height:100px;margin-bottom:5px;">' + tsv + '</textarea>');
  170. });
  171. });