rTWi stylish

A http://hyena.hu seed szerverén futó rTWi kinézetét módosítja

  1. // ==UserScript==
  2. // @name rTWi stylish
  3. // @namespace http://tothimre.changeip.net/svn
  4. // @description A http://hyena.hu seed szerverén futó rTWi kinézetét módosítja
  5. // @author Tóth Imre
  6. // @copyright (C) 2012-2015 Tóth Imre
  7. // @include http://dcore.hu/*
  8. // @include /https?://(debian\.intra|tothimre\.changeip\.net)/admin/rtwi/.*/
  9. // @include http://zilla.hu/*
  10. // @include http://denber.hu/*
  11. // @include http://zilla.webhop.org/*
  12. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js
  13. // @require https://gf.qytechs.cn/scripts/9136-color-picker/code/Color%20picker.js
  14. // @resource colorpicker_css http://tothimre.changeip.net/lib/ColorPicker/css/colorpicker.css
  15. // @resource colorpicker_background http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_background.png
  16. // @resource colorpicker_overlay http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_overlay.png
  17. // @resource colorpicker_select http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_select.gif
  18. // @resource colorpicker_indic http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_indic.gif
  19. // @resource colorpicker_hex http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_hex.png
  20. // @resource colorpicker_rgb_r http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_rgb_r.png
  21. // @resource colorpicker_rgb_g http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_rgb_g.png
  22. // @resource colorpicker_rgb_b http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_rgb_b.png
  23. // @resource colorpicker_hsb_h http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_hsb_h.png
  24. // @resource colorpicker_hsb_s http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_hsb_s.png
  25. // @resource colorpicker_hsb_b http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_hsb_b.png
  26. // @resource colorpicker_submit http://tothimre.changeip.net/lib/ColorPicker/images/colorpicker_submit.png
  27. // @version 2.3.4
  28. // @icon http://dcore.hu/favicon.ico
  29. // @grant GM_addStyle
  30. // @grant GM_getResourceText
  31. // @grant GM_getResourceURL
  32. // @grant GM_getValue
  33. // @grant GM_setValue
  34. // @svn-id $Id: rTWi stylish_v2.user.js 24 2014-02-27 08:33:14Z tothimre $
  35. // ==/UserScript==
  36.  
  37. /** rTWi stylish
  38. * Copyright (C) 2012-2015 Tóth Imre (ti00652 at gmail)
  39. *
  40. *
  41. * This program is free software: you can redistribute it and/or modify
  42. * it under the terms of the GNU General Public License as published by
  43. * the Free Software Foundation, either version 3 of the License, or
  44. * (at your option) any later version.
  45. *
  46. * This program is distributed in the hope that it will be useful,
  47. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  48. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  49. * GNU General Public License for more details.
  50. *
  51. * You should have received a copy of the GNU General Public License
  52. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  53. *
  54. *
  55. * Ez a program szabad szoftver; terjeszthető illetve módosítható a
  56. * Free Software Foundation által kiadott GNU General Public License
  57. * dokumentumában leírtak; akár a licenc 3-as, akár (tetszőleges) későbbi
  58. * változata szerint.
  59. *
  60. * Ez a program abban a reményben kerül közreadásra, hogy hasznos lesz,
  61. * de minden egyéb GARANCIA NÉLKÜL, az ELADHATÓSÁGRA vagy VALAMELY CÉLRA
  62. * VALÓ ALKALMAZHATÓSÁGRA való származtatott garanciát is beleértve.
  63. * További részleteket a GNU General Public License tartalmaz.
  64. *
  65. * A felhasználónak a programmal együtt meg kell kapnia a GNU General
  66. * Public License egy példányát; ha mégsem kapta meg, akkor
  67. * tekintse meg a <http://www.gnu.org/licenses/> oldalon (nem hivatalos magyar
  68. * fordítás: <http://gnu.hu/gplv3.html/>).
  69. */
  70.  
  71.  
  72. // beállítások; v2+: használd az UI-t a beállításhoz!
  73. var settings = {
  74. background_color: "FFFFFF", // háttér színe (hexa módban)
  75. active_speed_color: "FF00FF", // aktív torrent sebességének színe (hexa módban)
  76. ratio_limit: 1.000, // cél arány, ez felett és alatt más színnel lesznek színezve a torrentek
  77. ratio_color_good: "008000", // cél arányt elért torrent arányának színe (hexa módban)
  78. ratio_color_bad: "FF0000" // cél arányt el nem ért torrent arányának színe (hexa módban)
  79. };
  80.  
  81. var loc = window.location;
  82.  
  83. // függvények
  84. function init() {
  85. // beállítások betöltése
  86. $.extend(settings, JSON.parse(GM_getValue("settings_" + loc.hostname, "{}")));
  87.  
  88. // stílus beállítása
  89. GM_addStyle("body { background: none repeat scroll 0 0 #" + settings["background_color"] + " !important; }\n" + // ronda (fos)sárga háttér (#ECE5B6) eltüntetése
  90. ".tline:hover { background-color: #E0E0E0; }\n" + // torrent sorának kiemelése, ha fölékerül az egér
  91. ".ds_active_speed { color: #" + settings["active_speed_color"] + "; }\n" + // sebesség kiemelés stílusa
  92. ".ds_ratio_good { color: #" + settings["ratio_color_good"] + "; }\n" + // arány kiemelés stílusa
  93. ".ds_ratio_bad { color: #" + settings["ratio_color_bad"] + "; }"); // arány kiemelés stílusa
  94.  
  95.  
  96. // sebességek, arány kiemelése (hogy hogyan, azt függvénye válogatja)
  97. if (loc.pathname.match(/\/(index\.php|$)/)) {
  98. $("div.trates > span").each(highlight_active_speed); // torrent lista
  99. $("div.trates_total > span").each(highlight_active_speed); // globális sebesség
  100. $("div.tratio > span:last-child").each(highlight_active_ratio); // arány
  101. }
  102.  
  103. // beállítások menüpont
  104. var menu = $("#mainmenu");
  105. if (menu.length) {
  106. $("ul", menu).append('<li><a id="ds_settings" href="#">Stylish beállítások</a></li>');
  107. $("#ds_settings").click(show_settings);
  108. }
  109.  
  110. // tárhely adatok átírása a torrent hozzáadása fülön
  111. if (loc.search.match(/\?mod=addtorrent/)) {
  112. var disk_space_div = $("div.tufspace:first");
  113. var disk_space = disk_space_div.text().match(/(\d+)(\w+) \/ (\d+)(\w+)/);
  114. // " 45122M / 45056M"
  115. if (disk_space[2] == disk_space[4]) // ha mások a prefixek, nem csinálunk semmit
  116. disk_space_div.text(disk_space[0] + " használatban, " + (disk_space[3] - disk_space[1]) + disk_space[2] + " szabad");
  117. else
  118. disk_space_div.text(disk_space[0] + " használatban");
  119. }
  120.  
  121. // konzol alól is legyen jQuery
  122. unsafeWindow.$$=jQuery;
  123. }
  124.  
  125. // kiemeli a torrent sebességét
  126. function highlight_active_speed() {
  127. var speed = $(this).text().match(/([\d\.]+)/)[1];
  128. if (speed > 0)
  129. $(this).attr("class", "ds_active_speed");
  130. }
  131.  
  132. // kiemeli a torrent arányát
  133. function highlight_active_ratio() {
  134. var ratio = $(this).text().match(/([\d\.]+)/)[1];
  135. if (ratio >= settings["ratio_limit"])
  136. $(this).attr("class", "ds_ratio_good");
  137. else
  138. $(this).attr("class", "ds_ratio_bad");
  139. }
  140.  
  141. // felépíti és megjeleníti a beállításokat
  142. function show_settings() {
  143. if ($("#ds_settings_body").length) // ha már meg van nyitva a menü, kilépünk
  144. return false;
  145.  
  146. // ColorPicker stílus hozzáadása
  147. GM_addStyle(GM_getResourceText("colorpicker_css") + "\n" +
  148. ".colorpicker { background: url(" + GM_getResourceURL("colorpicker_background") + "); }\n" + // képek linkjének átírása; a CSS-t is át lehetne írni és úgy feltölteni, viszont akkor nem cache-elné GM a fájlt
  149. ".colorpicker_color div { background: url(" + GM_getResourceURL("colorpicker_overlay") + "); }\n" +
  150. ".colorpicker_color div div { background: url(" + GM_getResourceURL("colorpicker_select") + "); }\n" +
  151. ".colorpicker_hue div { background: url(" + GM_getResourceURL("colorpicker_indic") + ") left top; }\n" +
  152. ".colorpicker_hex { background: url(" + GM_getResourceURL("colorpicker_hex") + ") top; }\n" +
  153. ".colorpicker_rgb_r { background-image: url(" + GM_getResourceURL("colorpicker_rgb_r") + "); }\n" +
  154. ".colorpicker_rgb_g { background-image: url(" + GM_getResourceURL("colorpicker_rgb_g") + "); }\n" +
  155. ".colorpicker_rgb_b { background-image: url(" + GM_getResourceURL("colorpicker_rgb_b") + "); }\n" +
  156. ".colorpicker_hsb_h { background-image: url(" + GM_getResourceURL("colorpicker_hsb_h") + "); }\n" +
  157. ".colorpicker_hsb_s { background-image: url(" + GM_getResourceURL("colorpicker_hsb_s") + "); }\n" +
  158. ".colorpicker_hsb_b { background-image: url(" + GM_getResourceURL("colorpicker_hsb_b") + "); }\n" +
  159. ".colorpicker_submit { background: url(" + GM_getResourceURL("colorpicker_submit") + ") top; }");
  160.  
  161. /* nem működik
  162. // @resource layout_js http://tothimre.changeip.net/lib/ColorPicker/js/layout.js
  163. // @resource layout_css http://tothimre.changeip.net/lib/ColorPicker/css/layout.css
  164. // @resource select http://tothimre.changeip.net/lib/ColorPicker/images/select.png
  165. // @resource select2 http://tothimre.changeip.net/lib/ColorPicker/images/select2.png
  166. // @resource custom_background http://tothimre.changeip.net/lib/ColorPicker/images/custom_background.png
  167. // @resource custom_indic http://tothimre.changeip.net/lib/ColorPicker/images/custom_indic.gif
  168. // @resource custom_hex http://tothimre.changeip.net/lib/ColorPicker/images/custom_hex.png
  169. // @resource custom_rgb_r http://tothimre.changeip.net/lib/ColorPicker/images/custom_rgb_r.png
  170. // @resource custom_rgb_g http://tothimre.changeip.net/lib/ColorPicker/images/custom_rgb_g.png
  171. // @resource custom_rgb_b http://tothimre.changeip.net/lib/ColorPicker/images/custom_rgb_b.png
  172. // @resource custom_hsb_s http://tothimre.changeip.net/lib/ColorPicker/images/custom_hsb_s.png
  173. // @resource custom_hsb_h http://tothimre.changeip.net/lib/ColorPicker/images/custom_hsb_h.png
  174. // @resource custom_hsb_b http://tothimre.changeip.net/lib/ColorPicker/images/custom_hsb_b.png
  175. // @resource custom_submit http://tothimre.changeip.net/lib/ColorPicker/images/custom_submit.png
  176.  
  177. GM_addStyle(GM_getResourceText("layout_css") + "\n" + // fehér ColorPicker
  178. "#colorSelector { background: url(" + GM_getResourceURL("select") + "); }\n" +
  179. "#colorSelector div { background: url(" + GM_getResourceURL("select") + ") center; }\n" +
  180. "#colorSelector2 { background: url(" + GM_getResourceURL("select2") + "); }\n" +
  181. "#colorSelector2 div { background: url(" + GM_getResourceURL("select2") + ") center; }\n" +
  182. "#colorpickerHolder2 .colorpicker { background-image: url(" + GM_getResourceURL("custom_background") + "); }\n" +
  183. "#colorpickerHolder2 .colorpicker_hue div { background-image: url(" + GM_getResourceURL("custom_indic") + "); }\n" +
  184. "#colorpickerHolder2 .colorpicker_hex { background-image: url(" + GM_getResourceURL("custom_hex") + "); }\n" +
  185. "#colorpickerHolder2 .colorpicker_rgb_r { background-image: url(" + GM_getResourceURL("custom_rgb_r") + "); }\n" +
  186. "#colorpickerHolder2 .colorpicker_rgb_g { background-image: url(" + GM_getResourceURL("custom_rgb_g") + "); }\n" +
  187. "#colorpickerHolder2 .colorpicker_rgb_b { background-image: url(" + GM_getResourceURL("custom_rgb_b") + "); }\n" +
  188. "#colorpickerHolder2 .colorpicker_hsb_s { background-image: url(" + GM_getResourceURL("custom_hsb_s") + "); }\n" +
  189. "#colorpickerHolder2 .colorpicker_hsb_h { background-image: url(" + GM_getResourceURL("custom_hsb_h") + "); }\n" +
  190. "#colorpickerHolder2 .colorpicker_hsb_b { background-image: url(" + GM_getResourceURL("custom_hsb_b") + "); }\n" +
  191. "#colorpickerHolder2 .colorpicker_submit { background-image: url(" + GM_getResourceURL("custom_submit") + "); }");
  192. */
  193.  
  194. // beállítások megjelenítése
  195. GM_addStyle(".ds_bad_field { border: 2px solid red }\n" + // hibás mező stílusa
  196. ".ds_settings_left { float: left; font-weight: bold; width: 17%; }\n" + // bal oszlop stílusa
  197. ".ds_settings_right {float: left; width: 83%; }\n" + // jobb oszlop stílusa
  198. ".ds_formsend { margin: 1em 0 0 17%; }"); // gombsor stílusa
  199. var html = '<div id="ds_settings_body"><ul class="tuform">\n' +
  200. '<li><div class="ds_settings_left">Háttér színe:</div><div class="ds_settings_right"><input id="ds_background_color_field" title="Háttér színe (hexa módban)" type="text"></div><div class="clr"></div></li>\n' +
  201. '<li><div class="ds_settings_left">Aktív sebesség színe:</div><div class="ds_settings_right"><input id="ds_active_speed_color_field" title="Aktív torrent sebességének a színe (hexa módban)" type="text"></div><div class="clr"></div></li>\n' +
  202. '<li><div class="ds_settings_left">Cél arány:</div><div class="ds_settings_right"><input id="ds_ratio_limit_field" title="Cél arány (pl. 1.00)" type="text"></div><div class="clr"></div></li>\n' +
  203. '<li><div class="ds_settings_left">Szín a cél arány felett:</div><div class="ds_settings_right"><input id="ds_ratio_color_good_field" title="Torrent arányának a színe a cél arány felett (hexa módban)" type="text"></div><div class="clr"></div></li>\n' +
  204. '<li><div class="ds_settings_left">Szín a cél arány alatt:</div><div class="ds_settings_right"><input id="ds_ratio_color_bad_field" title="Torrent arányának a színe a cél arány alatt (hexa módban)" type="text"></div><div class="clr"></div></li>\n' +
  205. '<li class="ds_formsend"><input id="ds_save_settings" class="inputok" title="Beállítások mentése" value="Beállítások mentése" type="button"> <input id="ds_cancel_save" class="inputok" title="Mégsem" value="Mégsem" type="button"> <input id="ds_default_settings" class="inputok" title="Alapértelmezés visszaállítása" value="Alapértelmezés" type="button"></li>\n' +
  206. '</ul></div>';
  207. $("#maincol").html(html);
  208.  
  209. // mezők feltöltése az értékekkel, eseménykezelés (ciklusban, mert nem szeretem az ismétlődő sorokat :)
  210. var x = ["background_color", "active_speed_color", "ratio_limit", "ratio_color_good", "ratio_color_bad"];
  211. for (i in x)
  212. $("#ds_" + x[i] + "_field").val(settings[x[i]]).change(lock_page);
  213. $("#ds_background_color_field, #ds_active_speed_color_field, #ds_ratio_color_good_field, #ds_ratio_color_bad_field").ColorPicker({
  214. onSubmit: function(hsb, hex, rgb, el) {
  215. lock_page();
  216. $(el).val(hex.toUpperCase());
  217. $(el).ColorPickerHide();
  218. },
  219. onBeforeShow: function () {
  220. $(this).ColorPickerSetColor(this.value);
  221. }
  222. }).bind('keyup', function(){
  223. $(this).ColorPickerSetColor(this.value);
  224. });
  225. $("#ds_save_settings").click(save_settings);
  226. $("#ds_cancel_save").click(reload_page);
  227. $("#ds_default_settings").click(reset_settings);
  228. return false;
  229. }
  230.  
  231. // validálja és menti a beállításokat
  232. function save_settings() {
  233. // előző üzenet és mező kiemelés törlése
  234. $("#err").remove();
  235. $(".ds_bad_field").removeClass("ds_bad_field");
  236.  
  237. // color mezők validálása
  238. var x = ["background_color", "active_speed_color", "ratio_color_good", "ratio_color_bad"];
  239. var errors = 0;
  240. var field, val;
  241. for (i in x) {
  242. field = $("#ds_" + x[i] + "_field");
  243. val = $.trim(field.val());
  244. if (!val.match(/^[\da-f]{3,6}$/i)) {
  245. errors++;
  246. field.addClass("ds_bad_field");
  247. } else
  248. settings[x[i]] = val.toUpperCase();
  249. }
  250. if (errors) {
  251. show_info("Érvénytelen szín!");
  252. return false;
  253. }
  254.  
  255. // ratio mező validálása
  256. field = $("#ds_ratio_limit_field");
  257. val = $.trim(field.val());
  258. if (!val.match(/^\d+\.?\d*$/)) {
  259. field.addClass("ds_bad_field");
  260. show_info("Érvénytelen szám!");
  261. return false;
  262. } else
  263. settings["ratio_limit"] = parseFloat(val);
  264.  
  265. GM_setValue("settings_" + loc.hostname, JSON.stringify(settings));
  266. show_info("Beállítások elmentve");
  267. setTimeout(reload_page, 3000);
  268. return false;
  269. }
  270.  
  271. // törli a beállításokat és újratölti az oldalt
  272. function reset_settings() {
  273. GM_setValue("settings_" + loc.hostname, "{}");
  274. reload_page();
  275. }
  276.  
  277. // az oldal elhagyásakor figyelmeztető üzenetet jelenít meg (meta refresh ellen)
  278. function lock_page() {
  279. $(window).bind("beforeunload", function () {
  280. return "A változások még nincsenek mentve. Ha most elhagyod az oldalt, a módosítások elvesznek!";
  281. });
  282. }
  283.  
  284. // törli a figyelmezető üzenetet, és újratölti az oldalt
  285. function reload_page() {
  286. $(window).unbind("beforeunload");
  287. loc.reload()
  288. }
  289.  
  290. // információt jelenít meg a torrentlista felett
  291. function show_info(message) {
  292. $("#maincol").prepend('<div title="Kattints ide az elrejtéshez" id="err" style="cursor: pointer;"><div>' + message + '</div></div>');
  293. $("#err").click(function() {
  294. $(this).slideUp();
  295. setTimeout(function () { $("#err").remove(); }, 1000);
  296. });
  297. }
  298.  
  299.  
  300. // script aktiválása
  301. init();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址