IBM-Weather-UI

一个用于 weather.com 的优化 UI

  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.1
  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--AirQualityCard--"] {
  103. height: 270px;
  104. padding-left: 40px;
  105. padding-right: 40px;
  106. }
  107. [class*="AirQuality--leftCol--"],
  108. [class*="AirQuality--center--"] {
  109. width: 100% !important;
  110. flex-direction: column !important;
  111. justify-content: center !important;
  112. align-items: center !important;
  113. }
  114. [class*="AirQuality--leftCol--"] [class*="AirQuality--col--"]:first-of-type {
  115. width: 180px;
  116. height: 180px;
  117. padding: 0px !important;
  118. margin: 20px 0px 10px 0px;
  119. }
  120. [class*="AirQuality--AirQualityCard--"] [class*="DonutChart--donutchart--"] {
  121. transform: scale(3);
  122. transform-origin: 0 0;
  123. }
  124. [class*="DonutChart--innerValue--"] {
  125. font-size: 1.6em;
  126. }
  127. [class*="AirQuality--sm--"] [class*="AirQuality--leftCol--"] [class*="AirQuality--col--"]:last-of-type {
  128. padding: 0px !important;
  129. margin: 10px 0px 10px 0px;
  130. }
  131. [class*="AirQualityText--severity--"] {
  132. padding-bottom: 7px;
  133. }
  134. [dir] [class*="gradients--cloudyFoggyDay-contrast--"] {
  135. background-image: linear-gradient(#6e3f98,#a37697) !important;
  136. }
  137. [dir] [class*="gradients--clearNight-contrast--"] {
  138. background-image: linear-gradient(#113076,#135899) !important;
  139. }
  140. [class*="TodayDetailsCard--detailsContainer--"] {
  141. margin-bottom: 16px;
  142. }
  143. .video-label,
  144. .video-title {
  145. font-size: 14px !important;
  146. }
  147. [class*="DetailsSummary--wxIcon--"] {
  148. filter: brightness(0.9) saturate(2);
  149. }
  150. aside [id*="WxuTodayMapCard-main-"] [class*="Slideshow--Slideshow--"] {
  151. height: 600px;
  152. }
  153. [class*="TodayDetailsCard--detailsContainer--"] > div {
  154. margin: 0px 3px !important;
  155. }
  156. [class*="DetailsSummary--precip--"] > span {
  157. font-weight: bold;
  158. }
  159. [dir] [class*="DailyContent--narrative--"] {
  160. margin: 14px 0 14px 0;
  161. font-size: 0.9rem;
  162. }
  163. [id*="WxuAd-contentTop"] [class*="BaseAd--adWrapper--"] {
  164. margin: 0;
  165. }
  166. [id*="WxuAd-contentTop"] div[id*="google_ads_iframe"] {
  167. width: 100%;
  168. }
  169. [id*="WxuAd-contentTop"] iframe[id*="google_ads_iframe"] {
  170. width: 100%;
  171. background: #ffffff;
  172. border-radius: 6px;
  173. box-shadow: 0 0 12px 0 rgba(0,0,0,.2);
  174. }
  175. [id*="WxuAd-contentTop"] > div {
  176. padding: 0 !important;
  177. }
  178. </style>
  179. `));
  180. })(window.unsafeWindow, $);
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.