Mobile01+

Mobile01 自動轉址、載入圖片及影片框架

  1. // ==UserScript==
  2. // @name Mobile01+
  3. // @version 1.1
  4. // @description Mobile01 自動轉址、載入圖片及影片框架
  5. // @author Sofroumi
  6. // @namespace http://userscripts.org/scripts/show/94003
  7. // @homepage http://userscripts.org/scripts/show/94003
  8. // @include http://5i01.com/*
  9. // @include http://www.mobile01.com/*
  10. // @include https://www.mobile01.com/*
  11. // @match http://5i01.com/*
  12. // @match http://www.mobile01.com/*
  13. // @match https://www.mobile01.com/*
  14. // @icon data:image/gif;base64,R0lGODlhQABAAMQAAAtEE7jScZnELHOmKc/jtl+WFZ/Bdf///7vWmChiM3uhaqHFYl+HTZe+UoOzPLzYhiBXLczjpERxQKnLlt3uyKrLdmygIqDIPB1NIMTborvXfYazSRNKHa/PUdXxpnUAbSH5BAkAAB8ALAAAAABAAEAAAAX+4CeO5Kc9QaqubOu+qRaUdP1FwXIJV+//wKBwuOMtFjabjtcTOInQqO9ZvBiSo8hu5xhYCuCweEwum8GWgYPHeyQjT8d5Tq+LHcVITesckB0NR4KDhIWGhRsMYxYNPXolTWhfBQoIFJeYmZqbnJ0ED34Fkz4lATxfFl8Dlp2trq+XBoqjAjMjPX6pBRsElwS/wMHCw8TFwJcIqAUDPSMaAnJpuxEUBBERxtna2RQVynhuHx0CqBYMCL/X6tfp6+7v8PHW1xQGoqICSB8X0V8LwBkCEhA4wVKEgAgTKlzIUODBXxkc6MJzjV8BRQMeLByYgcCEBAqQNRxJkmPHCAb+Jl548MxLqgYREMicidCSAgDnKMSUGZBnTQQ9O/acSfQBTwRell2QISDXgAoEiEoFSkACAAwKeqnLMJVoLwUGMmAbthNoAzDMArRM87Qrggdw0RmAwIFDAgNRqVbjKlNjNQkJxD6YQLgw4b4IUqYRoGGtmgpu4Rq9xMAuBwwQMkOQABYd144KMACYMFDBZQgYUmOQwNWo4gGM11pwUEGybckdZWVOwFsz6tQQKlGYIIEDgKxAJ2D2vfptbQNeYDdu6oU23ArYs6MjjoE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iCGSvT+oAwyMAHNVIsCHkBVli7mnQn4kIsZyNeCXtdEDLKmMWCEzdxm2Bgg3gRBBIuABypglZkdjDQsAWLELLMrlkimi5tZz7KSqEfpnUB+VgEPVqyRxv4oaEJWPAEFEEAr1FTRkSfwmQAZpDFKCmCPAbNNTD5ZPUt4AIufFEuLbikzllXrE7dRpa5YyTAZxlKWpFRVirAivlhcghoosYqEtgbMYNqRmK6E5a30JhkPFCtBELhKiBJTvxRlyT9ZuU03rwmXYoZxhuoUnxoT90D8jfBDIEJkPB8gzM1g05jbjGcGBskA8ZSwN3T5ULKsuE9+srOV/tJmbeIpvwiUCDDdGeH+ZT4EOASEsqH8bNIIIfDPm2mhC4AwgFpu8zpHCpKM3VOATEUkSJDaJjEylelb4JY7ZriBHx5rEUX7+EhB3vKWB7GpOsdiDb0dQSIUEYdENrCBlDW0Mbbpo1aVmtV9yqCYs+mACKikhgvcqqVcTWtav+hKW5x0NsJyHVbVStesfnFjcojqWC9QHQcAgnIfU0vmtJo5wcJABYXVIPaKKRHY2OIW5ICrA6qqsMotthD6GcRlL3sElPlVIhZoRgkesINUqOGzfkWZalfL2tYCYgN+dQkPMlAD0jZFFKdF7WSpytveUnW3vg3ubyerW4w4IRw1yAAXUMGAAXwrQ9CNrnRIp0td+qACDyvBwg0CwAWXpOK74A2veMdLXtOqgQf80+4IUlAEJ7j3vfCNr3znC98LqEW9NFBWADrA3/76978ADrCA+9tELIQAADs=
  15. // ==/UserScript==
  16.  
  17. var Domain_Redirect = '0'; // 網域自動轉址 [0,1]
  18. var Newsdetail_Redirect = '1'; // 本站新聞自動轉址 [0,1]
  19. var Print_Redirect = '0'; // 友善列印自動轉址 [0,1]
  20. var Load_Image = '1'; // 自動載入圖片 [0,1]
  21. var Small_Image = '0'; // 優先載入小圖 [0,1] (需開啟 Load_Image)
  22. var Load_Video = '1'; // 自動載入影片框架 [0,1] (若為 0 以下功能皆無作用)
  23. var Video_Width = '480'; // 影片寬度 [200~738]
  24. var Video_Height = '385'; // 影片高度 [200~738]
  25. var Youtube_Iframe = '1'; // 包含 iframe 框架內 Youtube 影片 [0,1]
  26. var Youtube_autohide = '2'; // Youtube 自動隱藏撥放器介面 [0,1,2]
  27. var Youtube_autoplay = '0'; // Youtube 自動撥放 [0,1]
  28. var Youtube_fs = '1'; // Youtube 全螢幕撥放 [0,1]
  29. var Youtube_rel = '1'; // Youtube 顯示相關的影片 [0,1]
  30. var Youtube_showinfo = '1'; // Youtube 顯示影片資訊 [0,1]
  31. var Youtube_HTML5 = '0'; // Youtube HTML5 [0,1]
  32. var Remove_Video_Text = '1'; // 移除 "按這裡在新視窗中開啟影片" 文字 [0,1]
  33.  
  34. if (Domain_Redirect == '1' && window.location.hostname == '5i01.com') {
  35. var URL = window.location.href.replace('5i01.com' , 'www.mobile01.com');
  36. window.location.replace(URL);
  37. }
  38.  
  39. if (Newsdetail_Redirect == '1' && /newsdetail\.php/.test(window.location.href)) {
  40. A_Tag = document.getElementsByTagName('a');
  41. for (var i = 0 ; A_Tag.length > i ; i++) {
  42. if (A_Tag[i].innerHTML == '相關討論') {
  43. window.location.replace(A_Tag[i].href);
  44. }
  45. }
  46. }
  47.  
  48. if (Print_Redirect == '1') {
  49. if (/print\.php/.test(window.location.href)) {
  50. var URL = window.location.href.replace('print.php' , 'topicdetail.php');
  51. window.location.replace(URL);
  52. }
  53. A_Tag = document.getElementsByTagName('a');
  54. for (var i = 0 ; A_Tag.length > i ; i++) {
  55. if (A_Tag[i].innerHTML == '友善列印') {
  56. A_Tag[i].parentNode.removeChild(A_Tag[i]);
  57. }
  58. }
  59. }
  60.  
  61. if (Load_Image == '1') {
  62. A_Tag = document.getElementsByName('attachimg');
  63. while (A_Tag.length > 0) {
  64. if (window.location.hostname == '5i01.com' || Small_Image == '1') {
  65. Img_Tag = document.createElement('img');
  66. Img_Tag.setAttribute('src' , 'http://5i01.com/genimage.php?url=http://attach.mobile01.com/attach/' + A_Tag[0].id);
  67. Img_Tag.setAttribute('border' , '0');
  68. if (window.location.hostname == '5i01.com') {
  69. Img_Tag.setAttribute('onclick' , 'window.open("http://attach.mobile01.com/attach/' + A_Tag[0].id + '")');
  70. }
  71. else {
  72. Img_Tag.setAttribute('name' , A_Tag[0].href);
  73. Img_Tag.setAttribute('onclick' , 'this.src=this.name , this.title="" , this.style.cursor=""');
  74. }
  75. Img_Tag.setAttribute('title' , '按這裡看大圖');
  76. Img_Tag.setAttribute('style' , 'cursor: pointer');
  77. }
  78. else {
  79. Img_Tag = document.createElement('img');
  80. Img_Tag.setAttribute('src' , 'http://attach.mobile01.com/attach/' + A_Tag[0].id);
  81. Img_Tag.setAttribute('border' , '0');
  82. }
  83. A_Tag[0].parentNode.replaceChild(Img_Tag , A_Tag[0]);
  84. }
  85. A_Tag = document.getElementsByName('waypointimg');
  86. while (A_Tag.length > 0) {
  87. if (window.location.hostname == '5i01.com' || Small_Image == '1') {
  88. Img_Tag = document.createElement('img');
  89. Img_Tag.setAttribute('src' , 'http://5i01.com/genimage.php?url=http://attach.mobile01.com/waypoint/' + A_Tag[0].id);
  90. Img_Tag.setAttribute('border' , '0');
  91. if (window.location.hostname == 'www.mobile01.com') {
  92. Img_Tag.setAttribute('name' , A_Tag[0].href);
  93. Img_Tag.setAttribute('onclick' , 'this.src=this.name , this.title="" , this.style.cursor=""');
  94. }
  95. else {
  96. Img_Tag.setAttribute('onclick' , 'window.open("http://attach.mobile01.com/waypoint/' + A_Tag[0].id + '")');
  97. }
  98. Img_Tag.setAttribute('title' , '按這裡看大圖');
  99. Img_Tag.setAttribute('style' , 'cursor: pointer');
  100. }
  101. else {
  102. Img_Tag = document.createElement('img');
  103. Img_Tag.setAttribute('src' , 'http://attach.mobile01.com/waypoint/' + A_Tag[0].id);
  104. Img_Tag.setAttribute('border' , '0');
  105. }
  106. A_Tag[0].parentNode.replaceChild(Img_Tag , A_Tag[0]);
  107. }
  108. A_Tag = document.getElementsByTagName('a');
  109. for (var i = 0 ; A_Tag.length > i ; i++) {
  110. if (A_Tag[i].innerHTML == '載入圖片') {
  111. if (A_Tag[i].previousSibling != null && /»/.test(A_Tag[i].previousSibling.nodeValue)) {
  112. A_Tag[i].parentNode.removeChild(A_Tag[i].previousSibling);
  113. }
  114. if (A_Tag[i].nextSibling != null && /\s\|?\s/.test(A_Tag[i].nextSibling.nodeValue)) {
  115. A_Tag[i].parentNode.removeChild(A_Tag[i].nextSibling);
  116. }
  117. A_Tag[i].parentNode.removeChild(A_Tag[i]);
  118. i--;
  119. }
  120. }
  121. }
  122.  
  123. if (Load_Video == '1') {
  124. Video_Width = Number(Video_Width);
  125. Video_Height = Number(Video_Height);
  126. if (Video_Width < 200 || Video_Width > 738 || Video_Height < 200 || Video_Height > 738) {
  127. Video_Width = '200';
  128. Video_Height = '200';
  129. }
  130. A_Tag = document.getElementsByName('video');
  131. while (A_Tag.length > 0) {
  132. Embed_Tag = document.createElement('embed');
  133. Embed_Tag.setAttribute('src' , A_Tag[0].id);
  134. Embed_Tag.setAttribute('name' , 'Custom_Video');
  135. Embed_Tag.setAttribute('width' , '480');
  136. Embed_Tag.setAttribute('height' , '405');
  137. Embed_Tag.setAttribute('autostart' , 'false');
  138. A_Tag[0].parentNode.replaceChild(Embed_Tag , A_Tag[0]);
  139. }
  140. var YouTube_URL_Type = /youtu\.?be.*?[&\/\?=]([\w-]{11})(?=[#&\?]|$)/i;
  141. if (Youtube_Iframe == '1') {
  142. Iframe_Tag = document.getElementsByTagName('iframe');
  143. for (var i = 0 ; Iframe_Tag.length > i ; i++) {
  144. if (YouTube_URL_Type.test(Iframe_Tag[i].src)) {
  145. Span_Tag = document.createElement('span');
  146. A1_Tag = document.createElement('a');
  147. A1_Tag.setAttribute('href' , '#');
  148. A1_Tag.setAttribute('name' , 'externalvideo');
  149. A1_Tag.setAttribute('id' , Iframe_Tag[i].src);
  150. A1_Tag.setAttribute('target' , '_blank');
  151. A1_Tag.setAttribute('onClick' , 'return LoadExternalVideo(this.id);');
  152. Img_Tag = document.createElement('img');
  153. Img_Tag.setAttribute('src' , 'http://attach2.mobile01.com/image/showvideo.gif');
  154. Img_Tag.setAttribute('onload' , 'checkimagesize(this.id,this.width,this.height)');
  155. A1_Tag.appendChild(Img_Tag);
  156. A1_Tag.appendChild(document.createTextNode('按這裡檢視外部影片'));
  157. Span_Tag.appendChild(A1_Tag);
  158. Span_Tag.appendChild(document.createTextNode(' ('));
  159. A2_Tag = document.createElement('a');
  160. A2_Tag.setAttribute('href' , Iframe_Tag[i].src);
  161. A2_Tag.setAttribute('target' , '_blank');
  162. A2_Tag.appendChild(document.createTextNode('按這裡在新視窗中開啟影片'));
  163. Span_Tag.appendChild(A2_Tag);
  164. Span_Tag.appendChild(document.createTextNode(')'));
  165. Iframe_Tag[i].parentNode.replaceChild(Span_Tag , Iframe_Tag[i]);
  166. i--;
  167. }
  168. }
  169. }
  170. A_Tag = document.getElementsByName('externalvideo');
  171. while (A_Tag.length > 0) {
  172. var URL = A_Tag[0].id;
  173. var Video_Tag = 'embed';
  174. if (YouTube_URL_Type.test(URL)) {
  175. URL = 'http://www.youtube.com/embed/' + RegExp.$1;
  176. Video_Tag = 'iframe';
  177. if (Youtube_autohide == '0' || Youtube_autohide == '1') {
  178. URL = URL + '&autohide=' + Youtube_autohide;
  179. }
  180. if (Youtube_autoplay == '1') {
  181. URL = URL + '&autoplay=1';
  182. }
  183. if (Youtube_fs == '0') {
  184. URL = URL + '&fs=0';
  185. }
  186. if (Youtube_rel == '0') {
  187. URL = URL + '&rel=0';
  188. }
  189. if (Youtube_showinfo == '0') {
  190. URL = URL + '&showinfo=0';
  191. }
  192. if (Youtube_HTML5 == '1') {
  193. URL = URL + '&html5=1';
  194. }
  195. URL = URL.replace('&' , '?');
  196. }
  197. Embed_Tag = document.createElement(Video_Tag);
  198. switch (Video_Tag) {
  199. case 'embed':
  200. Embed_Tag.setAttribute('border' , '0');
  201. Embed_Tag.setAttribute('type', 'application/x-shockwave-flash');
  202. break;
  203. case 'iframe':
  204. Embed_Tag.setAttribute('frameborder', '0');
  205. break;
  206. }
  207. Embed_Tag.setAttribute('name' , 'Custom_Video');
  208. Embed_Tag.setAttribute('allowfullscreen' , 'true');
  209. Embed_Tag.setAttribute('height' , Video_Height);
  210. Embed_Tag.setAttribute('width' , Video_Width);
  211. Embed_Tag.setAttribute('src' , URL);
  212. A_Tag[0].parentNode.replaceChild(Embed_Tag , A_Tag[0]);
  213. }
  214. }
  215.  
  216. if (Remove_Video_Text == '1' && Load_Video == '1') {
  217. Video_Tag = document.getElementsByName('Custom_Video');
  218. for (var i = 0 ; Video_Tag.length > i ; i++) {
  219. while (Video_Tag[i].nextSibling.nodeValue == ' (' || Video_Tag[i].nextSibling.nodeName == 'A') {
  220. Video_Tag[i].parentNode.removeChild(Video_Tag[i].nextSibling);
  221. }
  222. if (/\).*/.test(Video_Tag[i].nextSibling.nodeValue)) {
  223. Video_Tag[i].nextSibling.replaceData(0 , 1 , '');
  224. }
  225. }
  226. }