IdlePixelMobile

A plugin to add mobile styling to idle-pixel.com

  1. // ==UserScript==
  2. // @name IdlePixelMobile
  3. // @namespace com.evolsoulx.idlepixel.mobile
  4. // @version 1.0.7
  5. // @description A plugin to add mobile styling to idle-pixel.com
  6. // @author evolsoulx
  7. // @license MIT
  8. // @grant GM_addStyle
  9. // @match *://idle-pixel.com/login/play*
  10. // @require https://greasyfork.org/scripts/441206-idlepixel/code/IdlePixel+.js
  11. // ==/UserScript==
  12. (function() {
  13. 'use strict';
  14. var viewport = document.querySelector("meta[name=viewport]");
  15. if(viewport){viewport.setAttribute('content', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0');}
  16. else{var metaTag=document.createElement('meta');
  17. metaTag.name = "viewport"
  18. metaTag.content = "width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
  19. document.getElementsByTagName('head')[0].appendChild(metaTag);
  20. }
  21.  
  22.  
  23. var mobileCSS = `
  24. @media only screen and (max-width: 1000px) {
  25.  
  26. body {}
  27.  
  28. /*reworking panel grid layout to be vertical*/
  29. #panels {
  30. background-color: lightblue !important;
  31. }
  32.  
  33. .top-bar {
  34. grid-column-start: 1 !important;
  35. grid-column-end: span 2 !important;
  36. grid-row-start: 1 !important;
  37. grid-row-end: span 1 !important;
  38. }
  39.  
  40. #menu-bar {
  41. grid-column-start: 1 !important;
  42. grid-column-end: span 2 !important;
  43. grid-row-start: 2 !important;
  44. grid-row-end: span 1 !important;
  45. }
  46.  
  47. #panels {
  48. grid-column-start: 1 !important;
  49. grid-column-end: span 2 !important;
  50. grid-row-start: 3 !important;
  51. grid-row-end: span 1 !important;
  52. }
  53.  
  54. /*Menu rework*/
  55. .left-menu-item {
  56. margin-bottom: 3px;
  57. display: inline-block;
  58. }
  59.  
  60. .hover.hover-menu-bar-item.left-menu-item {
  61. width: 90px;
  62. height: 90px;
  63. display: inline-block;
  64. border: 1px solid rgb(66, 66, 66);
  65. background-color: #54bcce;
  66. border-radius: 5pt;
  67. color: #F1F8F0;
  68. margin-bottom: 15px;
  69. text-align;
  70. center;
  71. }
  72.  
  73. .hover.hover-menu-bar-item.left-menu-item img {
  74. width: 100%;
  75. height: 100%;
  76. }
  77.  
  78. .color-light-red,
  79. .color-yellow,
  80. .color-silver {
  81. display: block;
  82. text-align: center;
  83. font-size: .9em;
  84. }
  85.  
  86. div[data-tooltip*=menu-bar-oil] .color-silver,
  87. #menu-bar-oil-in,
  88. #menu-bar-oil-out {
  89. display: inline;
  90. }
  91.  
  92. #menu-bar-buttons u {
  93. color: #F1F8F0;
  94. display: block;
  95. width: 100%;
  96. background-color: #0099A2;
  97. padding: 0px 10px;
  98. margin: 5px 0px;
  99. font-weight: bold;
  100. text-decoration: none;
  101. border: 1px none rgb(66, 66, 66);
  102. border-radius: 5pt;
  103. }
  104.  
  105. .hover.hover-menu-bar-item.left-menu-item span:nth-of-type(1),
  106. #menu-bar-buttons hr,
  107. #menu-bar-buttons br {
  108. white-space: nowrap;
  109. overflow: hidden;
  110. display: none;
  111. }
  112.  
  113. #menu-bar-buttons>hr:nth-child(26) {
  114. display: block;
  115. }
  116.  
  117. .hover.hover-menu-bar-item.left-menu-item[onclick*=quests],
  118. .hover.hover-menu-bar-item.left-menu-item[onclick*=shop],
  119. .hover.hover-menu-bar-item.left-menu-item[onclick*=player-market],
  120. .hover.hover-menu-bar-item.left-menu-item[onclick*=donor-shop],
  121. .hover.hover-menu-bar-item.left-menu-item[onclick*=achievements] {
  122. white-space: nowrap;
  123. overflow: hidden;
  124. }
  125.  
  126.  
  127. /*rework notifications*/
  128. #notifications-area div[id*=notification] {
  129. width: 100%;
  130. }
  131.  
  132. #ui-tweaks-notification-oil-full span {
  133. display: inline-block;
  134. }
  135.  
  136. #panels {
  137. padding: 3px 0px;
  138. }
  139.  
  140. .notifications-area {
  141. margin: 0px;
  142. padding: 0px;
  143. }
  144.  
  145. /*quick fix for modals*/
  146. .modal
  147. {
  148. top:0px !important;
  149. overflow-x: hidden;
  150. overflow-y: auto;
  151. }
  152.  
  153. }
  154. `;
  155. if (typeof GM_addStyle != "undefined") {
  156. GM_addStyle(mobileCSS);
  157. console.log('gm_addstyle');
  158. } else if (typeof PRO_addStyle != "undefined") {
  159. PRO_addStyle(mobileCSS);
  160. console.log('PRO_addStyle');
  161. } else if (typeof addStyle != "undefined") {
  162. addStyle(mobileCSS);
  163. console.log('addStyle');
  164. } else {
  165. var node = document.createElement("style");
  166. node.type = "text/css";
  167. node.appendChild(document.createTextNode(mobileCSS));
  168. var heads = document.getElementsByTagName("head");
  169.  
  170. if (heads.length > 0) {
  171. heads[0].appendChild(node);
  172. } else {
  173. // no head yet, stick it whereever
  174. document.documentElement.appendChild(node);
  175. }
  176. console.log('oldschool');
  177.  
  178. }
  179.  
  180.  
  181. class MobilePlugin extends IdlePixelPlusPlugin {
  182. constructor() {
  183. super("mobile", {
  184. about: {
  185. name: GM_info.script.name,
  186. version: GM_info.script.version,
  187. author: GM_info.script.author,
  188. description: GM_info.script.description,
  189. grant: GM_info.script.grant
  190. },
  191. config: [{
  192. type: "label",
  193. label: "Is this a mobile script?"
  194. },
  195. {
  196. id: "MyCheckbox",
  197. label: "Yes / No",
  198. type: "boolean",
  199. default: true
  200. }
  201. ]
  202. });
  203. }
  204.  
  205. onConfigsChanged() {
  206. }
  207.  
  208. onLogin() {
  209. console.log("MobilePlugin.onLogin " + mobileCSS);
  210. }
  211.  
  212. onMessageReceived(data) {
  213. // Will spam the console, uncomment if you want to see it
  214. //console.log("SamplePlugin.onMessageReceived: ", data);
  215. }
  216.  
  217. onVariableSet(key, valueBefore, valueAfter) {
  218. // Will spam the console, uncomment if you want to see it
  219. //console.log("SamplePlugin.onVariableSet", key, valueBefore, valueAfter);
  220. }
  221.  
  222. onChat(data) {
  223. // Could spam the console, uncomment if you want to see it
  224. //console.log("SamplePlugin.onChat", data);
  225. }
  226.  
  227. onPanelChanged(panelBefore, panelAfter) {
  228. console.log("MobilePlugin.onPanelChanged", panelBefore, panelAfter);
  229. }
  230.  
  231. onCombatStart() {
  232. console.log("MobilePlugin.onCombatStart");
  233. }
  234.  
  235. onCombatEnd() {
  236. console.log("MobilePlugin.onCombatEnd");
  237. }
  238.  
  239. }
  240.  
  241. const plugin = new MobilePlugin();
  242. IdlePixelPlus.registerPlugin(plugin);
  243.  
  244. })();
  245.