Advertisement
Guest User

Untitled

a guest
May 17th, 2015
3,539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.73 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Star Federation
  3. // @namespace starfederationuimod
  4. // @include http://www.star-kings.ru/*
  5. // @include http://star-kings.ru/*
  6. // @include http://starfederation.ru/*
  7. // @include http://www.starfederation.ru/*
  8. // @version 1
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. var run = function() {
  13.  
  14. $("body").append ( ' \
  15. <div id="gmRightSideBar" style="position:fixed; top:40; right: 0;background:#000000;z-index:99999999; "> \
  16. <p>Панель расширенных команд:</p> \
  17. <ul> \
  18. <!-- <li><a onClick="$(`#gmRightSideBar`).trigger(`RefreshWnd`);">Refresh</a></li> \
  19. <li><a onClick="$(`#gmRightSideBar`).trigger(`grabPlanetsData`);">Grab planets data</a></li> --> \
  20. <li><a onClick="$(`#gmRightSideBar`).trigger(`grabFlightPlan`);">Сохранить полетник</a></li> \
  21. <li><a onClick="$(`#gmRightSideBar`).trigger(`loadFlightPlan`);">Добавить команды к полетнику</a></li> \
  22. <!-- <li><a onClick="$(`#gmRightSideBar`).trigger(`empireViewUpdate`);">Empire view check</a></li> --> \
  23. </ul> \
  24. </div> \
  25. ' );
  26.  
  27. function addnextcmd(forms_html,id){
  28. if (id == forms_html.length)
  29. return;
  30.  
  31. var new_form = $("#WndFleet_comand_form_new");
  32. new_form[0].outerHTML = forms_html[id];
  33. var forms = $("form[id^='WndFleet_comand_form_']:last");
  34. forms.attr('id','WndFleet_comand_form_new');
  35. $("> input[name='icmd']",forms).attr('value','new');
  36. getWindow('WndFleet').add_comand('new');
  37. setTimeout(function(){addnextcmd(forms_html,id+1)}, 5000);
  38. }
  39.  
  40. $("#gmRightSideBar").bind('loadFlightPlan',function() {
  41. var text = window.prompt("Вставьте сохраненные команды: Ctrl+V, Enter", '');
  42. var forms_html = text.split("<;>");
  43. addnextcmd(forms_html,0);
  44. });
  45.  
  46. $("#gmRightSideBar").bind('grabFlightPlan',function() {
  47. var forms = $("form[id^='WndFleet_comand_form_']");
  48. var text = "";
  49. forms.each(function(index){
  50. if (index < forms.length-1)
  51. {
  52. if (index > 0)
  53. text = text + "<;>";
  54. var tmp = forms[index].outerHTML;
  55. text = text + tmp.replace(/<[^\/if][^>]*>/g,"").replace(/<\/[^f][^>]*>/g,"").replace(/title="[^"]*"/g,"").replace(/style="[^"]*"/g,"").replace(/onclick="[^"]*"/g,"").replace(/src="[^"]*"/g,"").replace(/class="[^"]*"/g,"").replace(/>[^<]*</g,"><").replace(/<img[^>]*>/g,"");
  56.  
  57. }
  58. });
  59. showMessageS("Сохраните эти данные в буффер обмена: ",text.replace(/&/g, '&amp;').replace(/"/g, '&quot;').replace(/'/g, '&#39;').replace(/</g, '&lt;').replace(/>/g, '&gt;'));
  60. //window.prompt("Сохранить в буффер обмена: Ctrl+C, Enter", text);
  61. });
  62.  
  63. GM_addStyle ( " \
  64. #gmRightSideBar { \
  65. position: fixed; \
  66. top: 100; \
  67. right: 900; \
  68. margin: 1ex; \
  69. padding: 1em; \
  70. background: orange; \
  71. width: 100px; \
  72. z-index: 9999; \
  73. opacity: 0.9; \
  74. } \
  75. #gmRightSideBar p { \
  76. font-size: 80%; \
  77. } \
  78. #gmRightSideBar ul { \
  79. margin: 0ex; \
  80. } \
  81. #gmRightSideBar a { \
  82. color: blue; \
  83. } \
  84. " );
  85.  
  86. }
  87.  
  88. var script = document.createElement("script");
  89. script.textContent = '(' + run.toString() + ')();';
  90. document.documentElement.appendChild(script);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement