Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name MVGroup Magnets
- // @version 6.7.4
- // @author emy
- // @match http://forums.mvgroup.org/index.php?showtopic=*
- // @require https://code.jquery.com/jquery-3.2.1.min.js
- // ==/UserScript==
- $magnet_list = [];
- function constructButton($torrent_list)
- {
- $button_html = '<div id="magnet-dl-all">Download All Magnets (' + $magnet_list.length + ')</div>';
- $frame = '<iframe style="display:none" name="magnetframe"></iframe>';
- $(document).find('iframe').prev().after($frame + $button_html);
- $(document).find('#magnet-dl-all').css({
- 'display' : 'inline-block',
- 'background-color' : '#c93030',
- 'padding' : '5px',
- 'color' : 'white',
- 'border-radius' : '3px',
- 'cursor' : 'pointer',
- 'font-weight' : 'bold',
- });
- }
- function fetchMagnetUrls($torrent_list)
- {
- $torrent_list.find(".magnetlink").each(function()
- {
- $magnet_url = $(this).attr('href');
- $magnet_list[$magnet_list.length] = $magnet_url;
- });
- if($magnet_list.length > 0)
- {
- constructButton($torrent_list);
- }
- }
- function waitForTorrentList()
- {
- if($(document).find('iframe').contents().find('#torrentlist').length >= 1)
- {
- fetchMagnetUrls($(document).find('iframe').contents().find('#torrentlist'));
- } else {
- setTimeout(waitForTorrentList, 1000);
- }
- }
- $(document).ready(function()
- {
- waitForTorrentList();
- $(document).on('click', '#magnet-dl-all', function()
- {
- jQuery.each($magnet_list, function(index, item)
- {
- window.open(item, 'magnetframe');
- });
- });
- $(document).on('mouseenter', '#magnet-dl-all', function()
- {
- $(this).css('background-color', 'rgb(221, 29, 29)');
- });
- $(document).on('mouseleave', '#magnet-dl-all', function()
- {
- $(this).css('background-color', '#c93030');
- });
- });
Add Comment
Please, Sign In to add comment