DotD Mutik Chatmover

moves the alliance chat provided by mutik's script(https://greasyfork.org/en/scripts/406-mutik-s-dotd-script) to a seperate window. Developement at https://github.com/Idrinth/DotD-Mutik-Chatmover

  1. // ==UserScript==
  2. // @name DotD Mutik Chatmover
  3. // @namespace http://idrinth.de/
  4. // @version 1.2.2
  5. // @description moves the alliance chat provided by mutik's script(https://greasyfork.org/en/scripts/406-mutik-s-dotd-script) to a seperate window. Developement at https://github.com/Idrinth/DotD-Mutik-Chatmover
  6. // @author Idrinth
  7. // @include http://www.kongregate.com/games/5thplanetgames/dawn-of-the-dragons*
  8. // @include http://kongregate.com/games/5thplanetgames/dawn-of-the-dragons*
  9. // @grant none
  10. // ==/UserScript==
  11. window.setTimeout ( function () {
  12. var idrinth4mutik = window.setInterval ( function () {
  13. if ( document.getElementById ( 'alliance_room' ) ) {
  14. window.clearInterval ( idrinth4mutik );
  15. var createButton = function() {
  16. var r = document.createElement ( 'div' );
  17. r.id = "idrinth_alliance_chat_wrapper";
  18. r.appendChild ( document.createElement ( 'a' ) );
  19. r.lastChild.appendChild ( document.createTextNode ( 'Alliance' ) );
  20. r.lastChild.setAttribute ( 'href', '#' );
  21. r.addEventListener ( 'click', function () {
  22. var el = document.getElementById ( 'alliance_room' );
  23. var el2 = document.getElementById ( 'idrinth_alliance_chat_wrapper' );
  24. var css = el2.getAttribute ( 'class' );
  25. if ( css === null ) {
  26. css = '';
  27. }
  28. if ( css.match ( /(^|\s)active(\s|$)/ ) ) {
  29. el.setAttribute ( 'class', 'disabled' );
  30. el2.setAttribute ( 'class', 'chat_room_tab' );
  31. } else {
  32. el2.setAttribute ( 'class', 'chat_room_tab active' );
  33. el.setAttribute ( 'class', '' );
  34. }
  35. } );
  36. r.setAttribute ( 'class', 'chat_room_tab active' );
  37. document.getElementById ( 'chat_room_tabs' ).appendChild ( r );
  38. };
  39. var handleRoom = function() {
  40. var room = document.getElementById ( 'alliance_room' );
  41. document.getElementsByTagName ( 'body' )[0].appendChild ( room );
  42. room.setAttribute ( 'draggable', 'true' );
  43. room.addEventListener ( 'mousedown', function (e) {
  44. var target = document.getElementById ( 'alliance_room' );
  45. target.mouseDown=true;
  46. target.dotdmutikchatmover = {
  47. x: target.getBoundingClientRect ().left - e.pageX,
  48. y: target.getBoundingClientRect ().top - e.pageY
  49. };
  50. } );
  51. var drag = function (e) {
  52. if ( !e.pageX || !e.pageY ) {
  53. return;
  54. }
  55. var target = document.getElementById ( 'alliance_room' );
  56. target.wasDragged=true;
  57. target.dotdmutikchatmover = target.dotdmutikchatmover ? target.dotdmutikchatmover : {
  58. x: 0,
  59. y: 0
  60. };
  61. target.setAttribute ( 'style', 'left:' + ( e.pageX + target.dotdmutikchatmover.x ) + 'px;top:' + ( e.pageY + target.dotdmutikchatmover.y ) + 'px' );
  62. };
  63. var mouseUp = function (e) {
  64. document.getElementById ( 'alliance_room' ).mouseDown=false;
  65. };
  66. room.ondragstart=function(e){
  67. e.dataTransfer.setData('text/plain', 'alliance_room');
  68. }
  69. document.getElementsByTagName('body')[0].addEventListener ( 'mouseup', mouseUp );
  70. room.addEventListener ( 'drag', drag );
  71. room.addEventListener ( 'dragend', drag );
  72. room.addEventListener ( 'drop', drag );
  73. room.addEventListener ( 'dragend', mouseUp );
  74. room.addEventListener ( 'drop', mouseUp );
  75. document.getElementsByTagName('body')[0].addEventListener ( 'mousemove', function (e) {
  76. if ( !e.pageX || !e.pageY) {
  77. return;
  78. }
  79. var target = document.getElementById ( 'alliance_room' );
  80. if(!target.wasDragged&&target.mouseDown) {
  81. target.dotdmutikchatmover = target.dotdmutikchatmover ? target.dotdmutikchatmover : {
  82. x: 0,
  83. y: 0
  84. };
  85. target.setAttribute ( 'style', 'left:' + ( e.pageX + target.dotdmutikchatmover.x ) + 'px;top:' + ( e.pageY + target.dotdmutikchatmover.y ) + 'px' );
  86. }
  87. } );
  88. room.addEventListener ( 'click', function (e) {
  89. if ( !e.target.getAttribute('class') || !(e.target.getAttribute('class')).match(/(^| )chatRaidLink($| )/) ) {
  90. return true;
  91. }
  92. e.preventDefault();
  93. e.stopPropagation();
  94. var raid = (e.target.getAttribute('class')).split(' ')[1].split('|');
  95. SRDotDX.request.joinRaid({
  96. boss:raid[2],
  97. id:raid[0],
  98. hash:raid[1],
  99. sid: raid[4]
  100. });
  101. return false;
  102. } );
  103. room.appendChild ( document.createElement ( 'span' ) );
  104. room.lastChild.innerHTML = '☀';
  105. room.lastChild.setAttribute ( 'title', 'Drag me!' );
  106. };
  107. var addStyles = function() {
  108. var styles = document.createElement ( 'style' );
  109. styles.appendChild ( document.createTextNode ( '#alliance_tab{display:none}'
  110. + '#alliance_room{z-index: 10000000;width:300px;background:#aaa;height:80%;position:fixed;top:10%;}'
  111. + '#alliance_room > span{cursor:move;-moz-user-select: none;-webkit-user-select: none;user-select: none;color:red;display:block;background-color:#fff;background-image:linear-gradient(to bottom,rgba(0,0,0,0.1),rgba(255,255,255,0.1),rgba(0,0,0,0.25)),linear-gradient(to right,rgba(0,0,0,0.1),rgba(255,255,255,0.1),rgba(0,0,0,0.25));width:1em;height:1em;padding:3px;position:absolute;border-radius:3px;top:0;margin-top:-0.25em;font-size:150%;right:0;margin-right:0.25em;}'
  112. + '#alliance_room.disabled{display:none}'
  113. + '#alliance_room > div{padding:1px;box-sizing:border-box}'
  114. + '#alliance_users{height:20%;overflow-y:scroll;background:rgba(0,0,0,0.25);color:#ddd}'
  115. + '#alliance_users > div{height:auto;width:100%;overflow:hidden}'
  116. + '#alliance_users > div > span{max-width:40%;overflow:hidden;display:block;float:left;padding:2px;box-sizing:border-box;margin:1px}'
  117. + '#alliance_users > div > span:nth-of-type(1){max-width:20%;border-radius:4px;background:darkRed;font-weight:bold}'
  118. + '#alliance_chat_window{height:70% !important;overflow-y:scroll;overflow-x:hidden;color:#ddd}'
  119. + '#alliance_chat_window img{max-width:95%}'
  120. + '#alliance_chat_window embed{max-width:95%;height: auto !important;}'
  121. + '#alliance_chat_window .username{font-weight:bold;color:red}'
  122. + '#alliance_chat_window .whisper{font-style:italic;color:#fff}'
  123. + '#alliance_chat_window .emote{color:orange}'
  124. + '#alliance_chat_window .emote .separator{display:none}'
  125. + '#alliance_chat_window .emote .username{display:none}'
  126. + '#alliance_chat_window a{color:lightcoral}'
  127. + '#alliance_chat_window > div > p{background:rgba(0,0,0,0.5);overflow:hidden}'
  128. + '#alliance_chat_window > div > p.even{background:rgba(0,0,0,0.65);}'
  129. + '#alliance_room > .chat_controls{height:10%}'
  130. + '#alliance_room textarea{resize:none}'
  131. + '#alliance_room > .chat_controls > textarea{background:rgba(0,0,0,0.65);color:#fff;height:100%;width:100%;box-sizing:border-box;display:block}' ) );
  132. document.getElementsByTagName ( 'head' )[0].appendChild ( styles );
  133. };
  134. createButton();
  135. handleRoom();
  136. addStyles();
  137. }
  138. }, 1000 );
  139. }, 1000 );