IBM-Weather-UI

一个用于 weather.com 的优化 UI

目前为 2021-06-18 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name IBM-Weather-UI
  3. // @name:ZH-CN IBM-Weather-UI
  4. // @name:ZH-TW IBM-Weather-UI
  5. // @namespace https://github.com/li-zyang
  6. // @version 1.0.0
  7. // @description An enchanced UI for weather.com
  8. // @description:ZH-CN 一个用于 weather.com 的优化 UI
  9. // @description:ZH-TW 一個用於 weather.com 的優化 UI
  10. // @author 阿昭
  11. // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACUAAAAlCAYAAADFniADAAADLklEQVRYhe2Wv46qQBTGeQQewUfgDeQNsKZZGwsqCS0ma4OlSGdBomtDosUaQotaKZ0kVFqoCZVGo4XSfre4Oyfin7vcTXbdwpOQDDBn+OXjzHeG4yQFvy24J1TGeEJljSdU1nhCZY3fD3U4JRhF86tLtXuPg5ouYuT1OnhZQ65UQV6vo+p4EHXzcVAsRN1E1fEAAFXHQ65UQaHWhKibWG12OJwSuu8H4eOghtEMgmqg7U9QtDoo1JroByF4WXsMFPt97Lmom+Akha5fAcWUAoBRNP8ZqLLdRcsfAwBa/hhlu5t6vj8mkGpNCKqBF+vtZ6AeHd8KNYrmOJyS/8678ilOUrDa7ND2J+AkBaNojn4QZi7oUTSnesyVKl+quSuleFlD259AtXvgJAUNd5Aq9lE0R8MdkAKrzQ4Nd0B+VbQ6EFQD4TKGqJto+xNUHQ+rzQ7A367RcAcEGy5jWvMuVKHWhGr3IOomBNVA0erQrmO+VLa7yJUqpEbZ7oKXNQJhvsbWKNSaqflFq4NcqYJ+EJIPvn6oexOq4Q7Ih9iYlzWMojmpUHU8+s39IIRq92jOpYWw/slKgZMUmlN1vJtt7ApqFM3Byxp4WcNyvU0ZJFNtGM0wjGb0kfcghKAan0Kxmu0HIYbRDNNFnA0KADhJoYm8rNF4GM1IflE3CZoppdo9NNwB1eUlFCsPUTdT9ZYJarqIsVxvaTxdxPRuud5iGM2wPyap++V6m8pZrreYLmLsjwn2xwTDaEZrMJVY/vn6d6EeHTehWIEXrQ5Wmx1ypcqXTDBLsFr8J5Rq9yCoBt6DkPof2znfEbfWvmuel4m8rNF2ZupxkgJBNQCAPIkV/v6Y0Hu24w6nBIJq0KExM9TNSR+LXjr7uf+IugnV7qEfhDSH5RWtDnkS+12cpCBcxtmhbil17kGrzQ6cpKBsd1NQVcej8WUeu3hZQ16vI6/Xybc+hWKJbX9CPe4SquEOqE0wNbJAtf0JNWnW626Wy63dxw52putjf0zw6njkR+yQ92K9Qao18ep4mC5itPwx+RXbIOd5zKda/hgv1htM1wcAvAdhqu/dhXp0PKGyxh869SPFcsnM3QAAAABJRU5ErkJggg==
  12. // @license CC0
  13. // @include https://weather.com/*
  14. // @exclude none
  15. // @require https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js
  16. // @grant GM_setValue
  17. // @grant GM_getValue
  18. // @grant GM_listValues
  19. // @grant GM_deleteValue
  20. // @grant GM_addValueChangeListener
  21. // @grant GM_removeValueChangeListener
  22. // @grant GM_addStyle
  23. // @grant GM_setClipboard
  24. // @grant GM_xmlhttpRequest
  25. // @grant GM_registerMenuCommand
  26. // @grant GM_unregisterMenuCommand
  27. // @grant GM_download
  28. // @grant GM_getTab
  29. // @grant GM_saveTab
  30. // @grant GM_getTabs
  31. // @grant GM_setClipboard
  32. // @grant GM_info
  33. // @grant GM_openInTab
  34. // @grant GM_notification
  35. // @grant GM_getResourceText
  36. // @grant GM_getResourceURL
  37. // @connect *
  38. // @noframes
  39. // @run-at document-end
  40. // @note v1.0.0 2021-06-18 随便改了改
  41. // ==/UserScript==
  42.  
  43. (function(window, $) {
  44. 'use strict';
  45. window.IBMWeatherUIJS = {};
  46. var s = window.IBMWeatherUIJS;
  47. function isDescendentOf (elem, pElemList) {
  48. while (!$(elem).filter('html').length) {
  49. var parent = $(elem).parent();
  50. for (var pElem of pElemList) {
  51. if (parent[0] == pElem) {
  52. return true;
  53. }
  54. }
  55. elem = parent;
  56. }
  57. return false;
  58. }
  59. s.isDescendentOf = isDescendentOf;
  60. if (location.toString().match(/https?:\/\/weather.com\/((\w|-)*\/)?weather\/today\//)) {
  61.  
  62. $('[id*="WxuAirQuality-sidebar-"]').after($('#todayDetails'));
  63. } else if (
  64. location.toString().match(/https?:\/\/weather.com\/((\w|-)*\/)?weather\/hourbyhour\//) ||
  65. location.toString().match(/https?:\/\/weather.com\/((\w|-)*\/)?weather\/tenday\//)
  66. ) {
  67. $('aside.region-sidebar').prepend($('[id*="WxuTodayMapCard-main-"]'));
  68. }
  69. $('html').append($(`
  70. <style class="IBMWeatherUIJS">
  71. [dir] [class*="gradients--rainyDay--"] {
  72. background-image: linear-gradient(#e1eaec,#d0f0d7,#f4fbf6);
  73. }
  74. [dir] [class*="gradients--cloudyFoggyDay--"] {
  75. background-image: linear-gradient(#dac8eb,#f5e2da,#fcf9f7);
  76. }
  77. [dir] [class*="gradients--default--"] {
  78. background-image: linear-gradient(#c0d6f2,#d4e2f5,#ffffff);
  79. }
  80. [dir] [class*="gradients--clearNight--"] {
  81. background-image: linear-gradient(#aab5ce,#a4cce2,#dfe7ea);
  82. }
  83. [class*="styles--overflowNav--"] {
  84. height: 50px;
  85. }
  86. [class*="styles--button--"] {
  87. height: 100%;
  88. }
  89. .LargeScreen [class*="CurrentConditions--header--"] [class*="CurrentConditions--timestamp--"] {
  90. font-size: 1rem;
  91. }
  92. [class*="styles--SavedLocations--"] {
  93. display: none;
  94. }
  95. [class*="MainMenuHeader--twcLogo--"] {
  96. width: 30px !important;
  97. height: 30px !important;
  98. }
  99. [class*="MainMenuHeader--wrapper--"] {
  100. height: auto;
  101. }
  102. [class*="AirQuality--leftCol--"] [class*="AirQuality--col--"]:first-of-type {
  103. width: 180px;
  104. height: 180px;
  105. padding: 0px !important;
  106. margin: 20px 0px 10px 0px;
  107. }
  108. [class*="AirQuality--AirQualityCard--"] [class*="DonutChart--donutchart--"] {
  109. transform: scale(3);
  110. transform-origin: 0 0;
  111. }
  112. [class*="AirQuality--AirQualityCard--"] {
  113. height: 270px;
  114. }
  115. [class*="AirQuality--leftCol--"],
  116. [class*="AirQuality--center--"] {
  117. width: 100% !important;
  118. flex-direction: column !important;
  119. justify-content: center !important;
  120. align-items: center !important;
  121. }
  122. [class*="AirQuality--sm--"] [class*="AirQuality--leftCol--"] [class*="AirQuality--col--"]:last-of-type {
  123. padding: 0px !important;
  124. margin: 10px 0px 10px 0px;
  125. }
  126. [class*="DonutChart--innerValue--"] {
  127. font-size: 1.6em;
  128. }
  129. [dir] [class*="gradients--cloudyFoggyDay-contrast--"] {
  130. background-image: linear-gradient(#6e3f98,#a37697) !important;
  131. }
  132. [dir] [class*="gradients--rainyDay-contrast--"] {
  133. background-image: linear-gradient(#004f69,#238665) !important;
  134. }
  135. [class*="TodayDetailsCard--detailsContainer--"] {
  136. margin-bottom: 16px;
  137. }
  138. .video-label,
  139. .video-title {
  140. font-size: 14px !important;
  141. }
  142. [class*="DetailsSummary--wxIcon--"] {
  143. filter: brightness(0.9) saturate(2);
  144. }
  145. aside [id*="WxuTodayMapCard-main-"] [class*="Slideshow--Slideshow--"] {
  146. height: 600px;
  147. }
  148. [class*="TodayDetailsCard--detailsContainer--"] > div {
  149. margin: 0px 3px !important;
  150. }
  151. [class*="DetailsSummary--precip--"] > span {
  152. font-weight: bold;
  153. }
  154. [dir] [class*="DailyContent--narrative--"] {
  155. margin: 14px 0 14px 0;
  156. font-size: 0.9rem;
  157. }
  158. [id*="WxuAd-contentTop"] [class*="BaseAd--adWrapper--"] {
  159. margin: 0;
  160. }
  161. [id*="WxuAd-contentTop"] div[id*="google_ads_iframe"] {
  162. width: 100%;
  163. }
  164. [id*="WxuAd-contentTop"] iframe[id*="google_ads_iframe"] {
  165. width: 100%;
  166. background: #ffffff;
  167. border-radius: 6px;
  168. box-shadow: 0 0 12px 0 rgba(0,0,0,.2);
  169. }
  170. [id*="WxuAd-contentTop"] > div {
  171. padding: 0 !important;
  172. }
  173. </style>
  174. `));
  175. })(window.unsafeWindow, $);
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.