From 742b0bf501d6ac115eac47b56e4b0241dc735f5e Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sat, 15 Aug 2015 18:35:06 +0200 Subject: [PATCH] UserScript + Torrents size --- README.md | 23 +++++++++++++++++++ src/Console/Command/TorrentsSearchCommand.php | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e8f38df..81d58fa 100644 --- a/README.md +++ b/README.md @@ -349,4 +349,27 @@ Help: ``` +### UserScript +![UserScript](https://upload.deblan.org/u/2015-08/55cf69d1.png "UserScript") + + +``` +// ==UserScript== +// @name Tranmission cli cmd +// @namespace t411 +// @include http*://www.t411.io/torrents/* +// @version 1 +// @grant none +// ==/UserScript== + +$('.btn').each(function() { + var $btn = $(this); + var $parent = $btn.parent(); + + if ($btn.attr('href').indexOf('download') !== -1) { + var id = $btn.attr('href').split('=')[1]; + $parent.append('

t411-console transmission:download ' + id + '

'); + } +}); +``` diff --git a/src/Console/Command/TorrentsSearchCommand.php b/src/Console/Command/TorrentsSearchCommand.php index bed6358..6360895 100644 --- a/src/Console/Command/TorrentsSearchCommand.php +++ b/src/Console/Command/TorrentsSearchCommand.php @@ -170,7 +170,7 @@ Usage: torrents:search QUERY [OPTIONS] protected function formatBytes($size, $precision = 2) { $base = log($size, 1024); - $suffixes = array('', 'k', 'M', 'G', 'T'); + $suffixes = array('', 'kB', 'MB', 'GB', 'TB'); return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)]; }