Advertisement
Guest User

Untitled

a guest
May 17th, 2015
673
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.16 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. var run = function() {
  12.  
  13. $("body").append ( ' \
  14. <div id="gmRightSideBar" style="position:fixed; top:40; right: 0;background:#000000;z-index:99999999; "> \
  15. <p>Панель расширенных команд:</p> \
  16. <ul> \
  17. <li><a onclick="$(`#gmRightSideBar`).trigger(`grabFlightPlan`);">Сохранить полетник</a></li> \
  18. <li><a onclick="$(`#gmRightSideBar`).trigger(`loadFlightPlan`);">Добавить команды к полетнику</a></li> \
  19. </ul> \
  20. </div> \
  21. ' );
  22.  
  23. function addnextcmd(forms_html,id){
  24. if (id == forms_html.length)
  25. return;
  26.  
  27. var new_form = $("#WndFleet_comand_form_new");
  28. new_form[0].outerHTML = forms_html[id];
  29. var forms = $("form[id^='WndFleet_comand_form_']:last");
  30. forms.attr('id','WndFleet_comand_form_new');
  31. $("> input[name='icmd']",forms).attr('value','new');
  32. getWindow('WndFleet').add_comand('new');
  33. setTimeout(function(){addnextcmd(forms_html,id+1)}, 5000);
  34. }
  35.  
  36. $("#gmRightSideBar").bind('loadFlightPlan',function() {
  37. var text = window.prompt("Вставьте сохраненные команды: Ctrl+V, Enter", '');
  38. var forms_html = text.split("<;>");
  39. addnextcmd(forms_html,0);
  40. });
  41.  
  42. $("#gmRightSideBar").bind('grabFlightPlan',function() {
  43. var forms = $("form[id^='WndFleet_comand_form_']");
  44. var text = "";
  45. forms.each(function(index){
  46. if (index < forms.length-1)
  47. {
  48. if (index > 0)
  49. text = text + "<;>";
  50. var tmp = forms[index].outerHTML;
  51. 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,"");
  52.  
  53. }
  54. });
  55. window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
  56. });
  57. GM_addStyle ( " \
  58. #gmRightSideBar { \
  59. position: fixed; \
  60. top: 100; \
  61. right: 900; \
  62. margin: 1ex; \
  63. padding: 1em; \
  64. background: orange; \
  65. width: 100px; \
  66. z-index: 9999; \
  67. opacity: 0.9; \
  68. } \
  69. #gmRightSideBar p { \
  70. font-size: 80%; \
  71. } \
  72. #gmRightSideBar ul { \
  73. margin: 0ex; \
  74. } \
  75. #gmRightSideBar a { \
  76. color: blue; \
  77. } \
  78. " );
  79. }
  80. var script = document.createElement("script");
  81. script.textContent = '(' + run.toString() + ')();';
  82. document.documentElement.appendChild(script);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement