Created
December 23, 2022 01:43
-
-
Save wolph/0cebe7dea0fa5fdd784808268167469f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name nzbking size and extension filtering | |
// @namespace http://wol.ph/ | |
// @version 0.1 | |
// @description Automatically hides downloads that are too small or only contain extensions such as exe, jpg, nfo, etc... | |
// @author wolph | |
// @match https://www.nzbking.com/* | |
// @icon https://icons.duckduckgo.com/ip2/nzbking.com.ico | |
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js | |
// @grant none | |
// ==/UserScript== | |
const SIZE_RE = /size: (\d+)(\w+)/; | |
const SIZE_MP = ['bytes', 'KB', 'MB', 'GB']; | |
const FILETYPES_RE = /filetypes: (.+)/; | |
const FILETYPE_RE = /\.(\w+)/g; | |
(function() { | |
'use strict'; | |
const results = $('div.search-result'); | |
for(const result of results){ | |
const subject = $(result, '.search-subject')[0].innerText; | |
const size_match = SIZE_RE.exec(subject); | |
if(!size_match)continue; | |
const size = size_match[1] * Math.pow(1000, SIZE_MP.indexOf(size_match[2])); | |
if(size < 40000000){ | |
$(result).remove(); | |
continue; | |
} | |
let filetypes_container = FILETYPES_RE.exec(subject); | |
if(filetypes_container === null || filetypes_container.length != 2)continue; | |
const filetypes = new Set(); | |
for(const match of filetypes_container[1].matchAll(FILETYPE_RE)){ | |
filetypes.add(match[1]); | |
} | |
filetypes.delete('EXE'); | |
filetypes.delete('JPG'); | |
filetypes.delete('NFO'); | |
filetypes.delete('JPEG'); | |
filetypes.delete('PNG'); | |
filetypes.delete('GIF'); | |
filetypes.delete('SFV'); | |
if(filetypes.size == 0){ | |
$(result).hide(); | |
continue; | |
} | |
console.log(size, filetypes); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment