// ==UserScript== // @name Multi-OCH Helper // @namespace cuzi // @license MIT // @description nopremium.pl and premiumize.me. Inserts a direct download link on several one-click-hosters and some container/folder providers. // @homepageURL https://openuserjs.org/scripts/cuzi/Multi-OCH_Helper // @icon https://greasyfork.org/system/screenshots/screenshots/000/003/479/original/icon.png // @version 16.1 // @include /^https:\/\/cvzi\.github\.io\/Userscripts\/index\.html\?link=.+/ // @include /^https:\/\/www\.nopremium\.pl\/files.*$/ // @include /^https:\/\/www\.premiumize\.me\/hosters\/?$/ // @include /^https:\/\/www\.premiumize\.me\/downloader.*$/ // @include http://download.serienjunkies.org/* // @include /^https?:\/\/(www\.)?filecrypt.cc\/Container\/\w+\.html.*$/ // @include http*filecrypt.cc/helper.html* // @include /^http:\/\/www\.firedrive\.com\/share\/(\w|-)+$/ // @include http://linkcrypt.ws/dir/* // @include http://linksave.in/* // @include /^http:\/\/ncrypt\.in\/folder\-\w+$/ // @include http*://*uploaded.net/folder/* // @include http*://*uploaded.net/f/* // @include http*://rapidgator.net/folder/* // @include http://www.relink.us/view.php?id=* // @include https://safelinking.net/p/* // @include http://linkshield.org/p/* // @include http://share-links.biz/* // @include http*://relink.to/view.php?id=* // @include http://extreme-protect.net/* // @include /^https?:\/\/(www\.)?1fichier\.com\/.+$/ // @include /^https?:\/\/\w+\.1fichier\.com\/?.*$/ // @include /^http:\/\/www\.4shared\.com\/[a-z]+\/\w+\/?(.+\.html)?$/ // @include /^https?:\/\/(www\.)?alfafile\.net\/file\/.+$/ // @include /^https?:\/\/(www\.)?bayfiles\.(net|com)\/file\/\w+\/.+$/ // @include /^http:\/\/billionuploads\.com\/\w+$/ // @include /^https?:\/\/(www\.)?catshare\.net\/.+$/ // @include /^https?:\/\/(www\.)?clicknupload\.(link|org)\/\w+\/?.*$/ // @include /^https?:\/\/(www\.)?datei\.to\/\?\w+$/ // @include /^https?:\/\/(www\.)?ddl\.to\/\w+$/ // @include /^https?:\/\/(www\.)?devilshare\.net\/view.+$/ // @include /^https?:\/\/(www\.)?file\.al\/\w+\/?.*$/ // @include /^https?:\/\/(www\.)?filefactory\.com\/file\/.+$/ // @include /^https?:\/\/www.filemonkey.in\/file\/.+$/ // @include /^https:\/\/filer\.net\/get\/\w+$/ // @include /^https?:\/\/(www\.)?filespace\.com\/\w+\/?$/ // @include /^https?:\/\/filestore\.to\/\?d=\w+$/ // @include /^http:\/\/www\.firedrive\.com\/file\/\w+$/ // @include /^https?:\/\/fireget\.com\/\w+\/?.*$/ // @include /^https?\:\/\/(www\.)?hitfile\.net\/\w+.*$/ // @include /^https?\:\/\/(www\.)?hil\.to\/\w+.*$/ // @include /^http:\/\/hugefiles\.net\/\w+\/?.*$/ // @include /^https:\/\/isra\.cloud\/\w+\/?.*$/ // @include /^https?:\/\/katfile\.com\/\w+\/?.*$/ // @include /^https?:\/\/lunaticfiles\.com\/\w+\/?.*$/ // @include /^https?:\/\/www\.mediafire\.com\/?\?.+$/ // @include /^https?:\/\/www\.mediafire\.com\/download\/.+$/ // @include /^https?:\/\/mega\.co\.nz\/\#\!\w+!*(\w|-)*$/ // @include /^https?:\/\/mega\.nz\/\#\!\w+!*(\w|-)*$/ // @include /^https?:\/\/modsbase\.com\/\w+\/?.*$/ // @include /^https?:\/\/openload\.co\/f\/.+$/ // @include /^https?:\/\/rapidgator\.net\/file\/[^#]+$/ // @include /^https?:\/\/rg\.to\/file\/[^#]+$/ // @include /^https?:\/\/(\w+\.)?rapidu\.net\/\w+.*$/ // @include /^https?\:\/\/(www\.)?rockfile\.(eu|co)\/\w+.*$/ // @include /^http:\/\/www\.sockshare\.com\/file\/\w+$/ // @include /^https?:\/\/(www\.)?storbit\.net\/file\/.+$/ // @include /^https?:\/\/(www\.)?spicyfile\.com\/\w+$/ // @include /^https?:\/\/streamin\.to\/.+$/ // @include /^https?:\/\/turbobit\.net\/\w+.*\.html$/ // @include /^https?:\/\/(www\.)?tusfiles\.net\/\w+$/ // @include /^https?:\/\/ubiqfile\.com\/\w+$/ // @include /^https?:\/\/uploadboy\.(me|com)\/\w+\/?.*$/ // @include /^https?:\/\/uploaded\.(net|to)\/file\/.+$/ // @include /^http:\/\/ul\.to\/.+$/ // @include /^https?:\/\/uploadgig\.com\/file\/download\/\w+\/?.*$/ // @include /^http:\/\/uploading\.com\/\w+\/?.*$/ // @include /^http:\/\/(www\.)?uploading\.site\/\w+.*$/ // @include /^http:\/\/uploadrocket\.net\/\w+(\/|\w|-|\.)+(\.html)?$/ // @include /^http:\/\/uptobox.com\/\w+(\/.*)?$/ // @include /^https?:\/\/userscloud\.com\/\w+.*$/ // @include /^https?:\/\/vidto\.me\/\w+\.?\w*$/ // @include /^https?:\/\/www\.wdupload\.com\/file\/\w+\/?.*$/ // @include /^https?:\/\/worldbytez\.com\/\w+$/ // @include /^https?:\/\/(www\.)?xubster\.com\/\w+\/?.*$/ // @include /^https?:\/\/www\.youtube\.com\/watch(\?v=|\/).+$/ // @include /^http:\/\/www\d*\.zippyshare\.com\/v\/\w+\/file\.html$/ // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js // @require https://greasyfork.org/scripts/13883-aes-js/code/aesjs.js // @require https://greasemonkey.github.io/gm4-polyfill/gm4-polyfill.js // @grant GM_registerMenuCommand // @grant unsafeWindow // @grant GM_xmlhttpRequest // @grant GM_openInTab // @grant GM_setClipboard // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant GM_listValues // @grant GM.xmlHttpRequest // @grant GM.openInTab // @grant GM.setClipboard // @grant GM.setValue // @grant GM.getValue // @grant GM.deleteValue // @grant GM.listValues // @downloadURL none // ==/UserScript== (async function() { "use strict"; // And to keep for myself whatever I may find? - Certainly. For yourself, and any friends you want to share with you. // This program inserts a download link on One-Click-Hosters and a few folder services. // If you click on the button, the current website address (or the links on the relink website) will be sent to nopremium.pl and you'll receive a nopremium.pl download link. // // Standard actions for the button are // * left mouse click: copy the link to the clipboard // * middle/wheel click: start download of the link // * right mouse click: open the nopremium.pl website and insert the link in the text box // * hovering the mouse over the button: open a menu with all the above option // var s_myname = "Multi-OCH Helper"; var s_referer = "multiochhelper"; var h_myname = "Multi-OCH Helper Highlight links"; var chrome = ~navigator.userAgent.indexOf("Chrome") var config = { position : [["bottom","top"],["left","right"]], position_desc : ['vertical','horizontal'], position_quest : 'Position of the Button. If you use "'+h_myname+'" this has to be set to bottom left', leftClick : ["clipboard","download","showLinks","openWebsite","menu","sendToJD","none"], leftClick_desc : ["Copy link to clipboard","Direct download","Show links like on website","Open the multihoster website","Show the extended menu","Send links to JDownloader","Do nothing"], leftClick_quest : "Action on left mouse click on button", middleClick : ["download","clipboard","showLinks","openWebsite","menu","sendToJD","none"], middleClick_desc : ["Direct download","Copy link to clipboard","Show links like on website","Open the multihoster website","Show the extended menu","Send links to JDownloader","Do nothing"], middleClick_quest : "Action on middle mouse/wheel click on button", rightClick : ["openWebsite","clipboard","showLinks","download","menu","sendToJD","none"], rightClick_desc : ["Show links like on website","Copy link to clipboard","Direct download","Open the multihoster website","Show the extended menu","Send links to JDownloader","Do nothing"], rightClick_quest : "Action on right mouse click on button", mouseOver : ["menu","clipboard","download","showLinks","openWebsite","sendToJD","none"], mouseOver_desc : ["Show the extended menu","Copy link to clipboard","Direct download","Show links like on website","Open the multihoster website","Send links to JDownloader","Do nothing"], mouseOver_quest : "Action on mouse hover over button", mouseOverDelay : 'int', mouseOverDelay_range : [0,700,3000], mouseOverDelay_quest : "Mouse hover time before action is executed.", mouseOverDelay_suffix : "milliseconds", newTab : 'bool', newTab_desc : ["Open in a new tab","Open in the same window"], newTab_quest : "Should websites be opened in a new tab?", updateHosterStatusInterval : 'int', updateHosterStatusInterval_range : [1,168,9999], updateHosterStatusInterval_quest : "How often should the status of the hosters be updated?", updateHosterStatusInterval_prefix : "Every", updateHosterStatusInterval_suffix : "hours", jDownloaderSupport : 'bool', jDownloaderSupport_desc : ["Show JDownloader button if JDownloader is runnning","Never show JDownloader button"], jDownloaderSupport_quest : ["Show a JDownloader button in the menu?"], }; var settings = {}; // Load settings var savedsettings = JSON.parse(await GM.getValue("settings","{}")); // e.g. { position : [0,1], newTab : 1 } for(var key in config) { if(key in savedsettings) { // Saved if(config[key] == 'int') { // Int settings[key] = parseInt(savedsettings[key],10); } else if(config[key] == 'string') { // String settings[key] = savedsettings[key].toString() } else if(config[key] == 'bool') { // Bool settings[key] = (savedsettings[key]=="true"||savedsettings[key]===true); } else if(Array.isArray(config[key][0])) { // Nested array if (!Array.isArray(savedsettings[key])) { try { const tmp = JSON.parse(savedsettings[key]) if(Array.isArray(tmp)) { savedsettings[key] = tmp } } catch(e) {} } settings[key] = []; for(var i = 0; i < savedsettings[key].length; i++) { settings[key].push(savedsettings[key][i]); } } else { // Array settings[key] = savedsettings[key]; } } else { // Default if(config[key] == 'int') { // Int settings[key] = config[key+"_range"][1]; } else if(config[key] == 'string') { // String settings[key] = '' // String defaults to empty string } else if(config[key] == 'bool') { // Bool settings[key] = true; } else if(Array.isArray(config[key][0])) { // Nested array defaults to first value for each array settings[key] = []; for(var i = 0; i < config[key].length; i++) { settings[key].push(config[key][i][0]); } } else { settings[key] = config[key][0]; // Array defaults to first value } } } var JDOWNLOADER = "http://127.0.0.1:9666/"; var SHAREBIZ_CNL2_URL = "http://share-links.biz/get/cnl2/"; var SHAREBIZ_RSDF_URL = "http://share-links.biz/get/rsdf/"; var SHAREBIZ_DLC_URL = "http://share-links.biz/get/dlc/"; var DCRYPTIT_UPLOAD_URL = "http://dcrypt.it/decrypt/upload"; var DCRYPTIT_CONTAINERLINK_URL = "http://dcrypt.it/decrypt/container"; var POSATIV_URL = "http://posativ.org/decrypt/rsdf"; var RELINKUS_GETFILE = "http://www.relink.us/frame.php?"; var SPINNERCSS = "/* http://www.designcouch.com/home/why/2013/05/23/dead-simple-pure-css-loading-spinner/*/\ .ochspinner {\ height:16px;\ width:16px;\ margin:0px auto;\ position:relative;\ animation: rotation .6s infinite linear;\ border-left:6px solid rgba(0,174,239,.15);\ border-right:6px solid rgba(0,174,239,.15);\ border-bottom:6px solid rgba(0,174,239,.15);\ border-top:6px solid rgba(0,174,239,.8);\ border-radius:100%;\ }\ @keyframes rotation {\ from {transform: rotate(0deg)}\ to {transform: rotate(359deg)}\ }\ "; var LOADINGBARBG = "background: #b4e391;\ background: linear-gradient(to bottom, #b4e391 0%,#61c419 50%,#b4e391 100%);" var show_oneclick_button = false; var show_oneclick_link = ""; var show_oneclick_FromHighlighScript_allLinks = document.location.host == "cvzi.github.io"; var show_oneclick_FromHighlighScript_allLinks_loc = false; var show_oneclick_FromHighlighScript_allLinks_links = ""; var show_oneclick_FromHighlighScript_selectedLinks = false; var show_oneclick_FromHighlighScript_selectedLinks_loc = false; var show_oneclick_FromHighlighScript_selectedLinks_links = ""; var links_beforeSelection = false; var multi = { 'premiumize.me' : new (function() { var self = this; this.config = { 'apikey' : 'string', 'apikey_quest' : 'Enter your premiumize.me API key', 'apikey_prefix' : 'API key: ', 'apikey_suffix' : ' find it under https://www.premiumize.me/account' }; this.key = 'premiumize.me'; this.name = 'premiumize'; this.homepage = 'https://www.premiumize.me/'; this.updateStatusURL = 'https://www.premiumize.me/hosters'; this.updateStatusURLpattern = /https:\/\/www\.premiumize\.me\/hosters\/?/; this.updateDownloadProgressInterval = 5000; this.updateDownloadProgressInterfaceInterval = 500; this.status = {}; this.init = async function() { self.status = JSON.parse(await GM.getValue(self.key+"_status","{}")); self.lastUpdate = new Date(await GM.getValue(self.key+"_status_time",0)); }; this.settings = {}; this.loadSettings = async function(silent) { // Load settings, use first value as default var savedsettings = JSON.parse(await GM.getValue(self.key+"_settings","{}")); for(var key in self.config) { if(key.endsWith("desc") || key.endsWith("range") || key.endsWith("quest") || key.endsWith("prefix") || key.endsWith("suffix")) { continue; } if(key in savedsettings) { // Saved if(self.config[key] == 'int') { // Int self.settings[key] = parseInt(savedsettings[key],10); } else if(self.config[key] == 'string') { // String self.settings[key] = savedsettings[key].toString(); } else if(config[key] == 'bool') { // Bool self.settings[key] = savedsettings[key]=="true"||savedsettings[key]===true; } else if(Array.isArray(savedsettings[key])) { // Nested array self.settings[key] = []; for(var i = 0; i < savedsettings[key].length; i++) { self.settings[key].push(savedsettings[key][i]); } } else { // Array self.settings[key] = savedsettings[key]; } } else { // Default if(self.config[key] == 'int') { // Int self.settings[key] = self.config[key+"_range"][1]; } else if(self.config[key] == 'string') { // String self.settings[key] = ''; // String defaults to empty string } else if(config[key] == 'bool') { // Bool self.settings[key] = true; } else if(Array.isArray(self.config[key][0])) { // Nested array defaults to first value for each array self.settings[key] = []; for(var i = 0; i < self.config[key].length; i++) { self.settings[key].push(self.config[key][i][0]); } } else { self.settings[key] = self.config[key][0]; // Array defaults to first value } } } if(!self.settings.apikey && !silent) { // Try to get the apikey from the website GM.xmlHttpRequest({ method: "GET", url: self.homepage+"account", onerror: function(response) { console.log(s_myname+": premiumize.me API Key could not be loaded") setStatus('You have not set you premiumize.me Api key ') }, onload: function(response) { let s = '' try { s = response.responseText.split('class="apipass"')[1].split('')[1] } catch(e) { } if (s) { self.settings.apikey = s GM.setValue(self.key+"_settings", JSON.stringify(self.settings)); console.log(s_myname+": premiumize.me API Key was loaded from account and saved!") } else { setStatus('You need to set you premiumize.me Api key') } } }); } }; this.updateStatus = async function() { // Update list of online hosters if(document.location.href.match(self.updateStatusURL)) { // Read and save current status of all hosters self.status = {}; $("table.table tr>td:first-child").each(function() { var text = $(this).text(); if(text.match(/^\s*[0-9a-z-]+\.\w{0,6}\s*$/i)) { var name = text.match(/^\s*([0-9a-z-]+)\.\w{0,6}\s*$/i)[1]; self.status[name.toLowerCase()] = true; } }); await GM.setValue(self.key+"_status",JSON.stringify(self.status)); await GM.setValue(self.key+"_status_time",""+(new Date())); console.log(s_myname+": "+self.name+": Hosters ("+Object.keys(self.status).length+") updated"); } else { alert(s_myname+"\n\nError: wrong update URL"); } }; this.isOnline = function(hostername) { return hostername in self.status && self.status[hostername]; }; this.getOpenWebsiteURL = function(urls) { // Return a link to the premiumize.me website that will insert the links var url = this.homepage+"downloader?link:"+encodeURIComponent(urls.join("\n")); return url; }; this.checkLink = function(url,cb) { // check whether the link is supported and online var host = url.match(/https?:\/\/(.+?)\//)[1]; var hoster = host.split("."); hoster.pop(); hoster = hoster.pop().replace("-",""); cb(this.isOnline(hoster)); }; this.getResults = function(urls,cb) { // cb($node,linkNumber) -- $node contains the result, linkNumber is the number of links that should be online i.e. number of hashes alert("This function does not work for "+this.name); }; this._notLoggedIn = false; this.getLinks = async function(urls,cb) { await showConfirm("fairPointsWarning","You will be charged premiumize fair points for generating "+(urls.length>1?(""+urls.length+" files"):("one file"))+"!

Generate links?",function() { self._getLinks(urls, cb); },function() { setStatus("Operation canceled!",0); cb([],-1); },self); }; this._getLinks = function(urls,cb) { var N = urls.length; var downloadLinks = []; var errors = []; for(var i = 0; i < urls.length; i++) { this._addSingleTransfer(urls[i], function(downloadlink, originallink, message) { if(downloadlink) { downloadLinks.push(downloadlink); } else { errors.push([originallink, message]); } }); } var checkprogress = function() { if(self._notLoggedIn) { // Stop checking and open premiumize homepage setStatus(self.name+" error: Not logged in!",0); GM.openInTab(self.homepage); cb([], -1); return; } if(N == errors.length) { // All errors cb(false, -1); if (errors.length == 1 && errors[0][1]) { setStatus(errors[0][1], 0); } else { alert("Errors occured\n"+errors.length+" links failed:\n\n"+errors.join("\n")); } } else if(N == downloadLinks.length+errors.length) { // All finished cb(downloadLinks); if(errors.length > 0) { // Errors occured alert("Errors occured\n"+errors.length+" links failed:\n\n"+errors.join("\n")); } } else { // not finished yet window.setTimeout(checkprogress, self.updateDownloadProgressInterfaceInterval); } }; window.setTimeout(checkprogress, self.updateDownloadProgressInterfaceInterval * Math.max(5, N)); }; this._addSingleTransfer = function(url, cb) { GM.xmlHttpRequest({ method: "POST", url: self.homepage+"api/transfer/create", data: "apikey="+encodeURIComponent(self.settings.apikey)+"&src="+encodeURIComponent(url), headers: { "Content-Type": "application/x-www-form-urlencoded", "Cache-Control" : "no-cache" }, onerror: function(response) { console.log(s_myname+": GM.xmlHttpRequest error: "+self.homepage+"api/transfer/create"); console.log(response); cb(false, url, 'GM.xmlHttpRequest error: api/transfer/create'); }, onload: function(response) { var result = JSON.parse(response.responseText); /* {"status":"success","type":"savetocloud","id":"gfwRtdgd5fgdfgfhgfhf","name":"test.zip"} {"status":"error","error":"duplicate","id":"gfdgd5fgFddfgfhgfhf","message":"You already have this job added."} {"status":"error","message":"This link is not available on the file hoster website"} */ if("id" in result && result.id) { window.setTimeout(function() { self._getFileFromTransfer(url, result.id, cb) }, 1000) if("message" in result) { addStatus(result["message"],-1); } } else { if("message" in result && !self._notLoggedIn) { addStatus(result["message"],-1); if(~result["message"].indexOf("log")) { self._notLoggedIn = true; } } cb(false, url, "message" in result?result["message"]:response.responseText); } } }); }; this._getFileFromTransfer = function(url, transferId, cb) { GM.xmlHttpRequest({ method: "GET", url: self.homepage+"api/transfer/list?apikey=" + encodeURIComponent(self.settings.apikey), headers: { "Content-Type": "application/x-www-form-urlencoded", "Cache-Control" : "no-cache" }, onerror: function(response) { console.log(s_myname+": GM.xmlHttpRequest error: "+self.homepage+"api/transfer/list"); console.log(response); cb(false, url, "GM.xmlHttpRequest error: /api/transfer/list"); }, onload: function(response) { var result = JSON.parse(response.responseText); /* { "status": "success", "transfers": [ { "id": "xXFDSXXFDSGD", "name": "test.zip", "message": null, "status": "finished", "progress": 0, "folder_id": "gfjdfsuigjfdoikfsadf", "file_id": "trhgf982u30fjklfsdag" } ] } { "status": "success", "transfers": [ { "id":"xXFDSXXFDSGD", "name":"test.zip", "message":"Initializing Download...", "status":"running", "progress":0, "folder_id":"gfjdfsuigjfdoikfsadf", "file_id":null } ] } */ if(result.status == "success" && "transfers" in result) { for(let i = 0; i < result.transfers.length; i++) { if (result.transfers[i].id == transferId) { if (result.transfers[i].file_id) { // Finished window.setTimeout(function() { self._getSingleLink(url, result.transfers[i].file_id, cb) }, result.transfers[i].status == "finished"?10:self.updateDownloadProgressInterval) } else { // Downloading if('message' in result.transfers[i] && result.transfers[i].message) { setStatus(result.transfers[i].message,-1); } window.setTimeout(function() { self._getFileFromTransfer(url, transferId, cb) }, self.updateDownloadProgressInterval) } return } } } if('message' in result && result.message) { alert(s_myname+'\n\nCould not get /api/transfer/list\nError:\n'+result.message) } cb(false, url, 'Could not find url in transfer list'); } }); }; this._getSingleLink = function(url, fileId, cb) { GM.xmlHttpRequest({ method: "POST", url: self.homepage+"api/item/details", data: "apikey="+encodeURIComponent(self.settings.apikey)+"&id="+encodeURIComponent(fileId), headers: { "Content-Type": "application/x-www-form-urlencoded", "Cache-Control" : "no-cache" }, onerror: function(response) { console.log(s_myname+": GM.xmlHttpRequest error: "+self.homepage+"api/item/details"); console.log(response); cb(false, url, "GM.xmlHttpRequest error: /api/item/details"); }, onload: function(response) { var result = JSON.parse(response.responseText); /* { "id": "xxXxXxxxXxxx", "name": "test.zip", "size": 156, "created_at": 1572458477, "transcode_status": "not_applicable", "folder_id": "XxXXXxxxxxx", "ip": "1.1.1.1", "acodec": "", "vcodec": "", "mime_type": "application/zip", "opensubtitles_hash": "", "resx": "", "resy": "", "duration": "", "virus_scan": "ok", "type": "file", "link": "https://down.host.example.com/dl/abcdefg/test.zip", "stream_link": null } */ if("link" in result && result.link) { cb(result.link, url); } else { window.setTimeout(function () { self._getSingleLink(url, fileId, cb) }, self.updateDownloadProgressInterval) } } }); }; })(), 'nopremium.pl' : new (function() { var self = this; this.config = { 'mode' : ['transfer','premium','none'], 'mode_desc' : ['Transfer User (Pakiety Transferowe)','Premium User (Konta Premium)','No account'], 'mode_quest' : 'What kind of account do you have at nopremium.pl', 'downloadmode' : ['direct','server'], 'downloadmode_desc' : ['Direct download (TRYB SZYBKIEGO POBIERANIA)','Downloading via NoPremium.pl server (TRYB POBIERANIA NA SERWERY)'], 'downloadmode_quest' : ['Which download mode do you want to use?'] }; this.key = 'nopremium.pl'; this.name = 'NoPremium.pl'; this.homepage = 'https://www.nopremium.pl/'; this.updateStatusURL = 'https://www.nopremium.pl/files'; this.updateStatusURLpattern =/https?:\/\/www\.nopremium\.pl\/files\/?/; this.updateDownloadProgressInterval = 5000; var mapHosterName = function(name) {return name.replace("-","")}; this.status = {}; this.init = async function() { self.status = JSON.parse(await GM.getValue(self.key+"_status","{}")); self.lastUpdate = new Date(await GM.getValue(self.key+"_status_time",0)); }; this.settings = {}; this.loadSettings = async function(silent) { // Load settings, use first value as default var savedsettings = JSON.parse(await GM.getValue(self.key+"_settings","{}")); for(var key in self.config) { if(key.endsWith("desc") || key.endsWith("range") || key.endsWith("quest") || key.endsWith("prefix") || key.endsWith("suffix")) { continue; } if(key in savedsettings) { // Saved if(self.config[key] == 'int') { // Int self.settings[key] = parseInt(savedsettings[key],10); } else if(self.config[key] == 'string') { // String self.settings[key] = savedsettings[key].toString(); } else if(config[key] == 'bool') { // Bool self.settings[key] = savedsettings[key]=="true"||savedsettings[key]===true; } else if(Array.isArray(savedsettings[key])) { // Nested array self.settings[key] = []; for(var i = 0; i < savedsettings[key].length; i++) { self.settings[key].push(savedsettings[key][i]); } } else { // Array self.settings[key] = savedsettings[key]; } } else { // Default if(self.config[key] == 'int') { // Int self.settings[key] = self.config[key+"_range"][1]; } else if(self.config[key] == 'string') { // String self.settings[key] = ''; // String defaults to empty string } else if(config[key] == 'bool') { // Bool self.settings[key] = true; } else if(Array.isArray(self.config[key][0])) { // Nested array defaults to first value for each array self.settings[key] = []; for(var i = 0; i < self.config[key].length; i++) { self.settings[key].push(self.config[key][i][0]); } } else { self.settings[key] = self.config[key][0]; // Array defaults to first value } } } }; this.updateStatus = async function() { // Update list of online hosters if(document.location.href.match(self.updateStatusURL)) { // Read and save current status of all hosters self.status = {}; $("#servers a[title]").each(function() { var name = mapHosterName(this.title); self.status[name] = true; }); await GM.setValue(self.key+"_status",JSON.stringify(self.status)); await GM.setValue(self.key+"_status_time",""+(new Date())); console.log(s_myname+": "+self.name+": Hosters ("+Object.keys(self.status).length+") updated"); } else { alert(s_myname+"\n\nError: wrong update URL"); } }; this.isOnline = function(hostername) { return hostername in self.status && self.status[hostername]; }; this.getOpenWebsiteURL = function(urls) { // Return a link to the nopremium.pl website that will insert the links var url = this.homepage+"files?link:"+encodeURIComponent(urls.join("\n")); return url; }; var getHashs = function(urls,cb,silent) { // cb(hashes,sizestring) setStatus("Sending "+(urls.length===1?"one link":(urls.length+" links")),-1); GM.xmlHttpRequest({ method: "POST", url: self.homepage+"files", data: "watchonline=&session="+(Math.round(Math.random()*1234567))+"&links="+encodeURIComponent(urls.join("\n")), headers: { "Content-Type": "application/x-www-form-urlencoded", "Cache-Control" : "no-cache", // "Referer" : "https://www.nopremium.pl/files" // FIREFOX57 }, onload: function(response) { if(response.responseText.indexOf('') != -1) { setStatus(self.name+" error: Not logged in!",0); GM.openInTab(self.homepage); return cb([],-1); } var hashes = []; // Find hashes var re = /name\=\"hash(\d+)\" value\=\"(\w+)\"/g; // size = ma[1]+" "+ma[2]; } setStatus(self.name+" identified "+(hashes.length===1?"one online file":(hashes.length+" online files")),-1); cb(hashes,size); } }); }; this.checkLink = function(url,cb) { // check whether the link is supported and online // cb(boolresult) return getHashs([url],function(hashes,size) { cb(hashes.length === 1); },true); }; this.getResults = function(urls,cb,hashes) { // cb($node,linkNumber) -- $node contains the result, linkNumber is the number of links that should be online i.e. number of hashes // Get download links from nopremium.pl and show the usual info about the file, that is normally shown on nopremium.pl if(typeof hashes == "undefined") { // 1. Get hashes and show transfer warning getHashs(urls,async function(hashes,size) { if(settings.mode == 'transfer') { await showConfirm("transferWarning","You will be charged "+size+" 'Transfer' for generating "+(hashes.length>1?(""+hashes.length+" files"):("one file"))+"!

Generate links?",function() { this.getResults(urls,cb,hashes); },null,self); } else if(hashes.length > 0) { self.getResults(urls,cb,hashes); } else if(size === -1) { // Error was already handled (probably not logged in) cb(false,0); } else { // No files found setStatus("No online/available files",0); cb(false,0); } }); return; } // 2. Work with hashes var $resultContainer = $("
").attr('id','generated-links'); var mode = self.settings.downloadmode == 'direct'?0:1; // 0 -> direct , 1 -> via server GM.xmlHttpRequest({ method: "POST", url: self.homepage+"files", data: "insert=1&mode="+mode+"&hh=0&hash[]="+hashes.join("&hash[]=")+"&", headers: { "Content-Type": "application/x-www-form-urlencoded", "Cache-Control" : "no-cache", // "Referer" : "https://www.nopremium.pl/files" // FIREFOX57 }, onload: function(response) { GM.xmlHttpRequest({ method: "POST", url: self.homepage+"files", data: "loadfiles=1", headers: { "Content-Type": "application/x-www-form-urlencoded", "Cache-Control" : "no-cache", // "Referer" : "https://www.nopremium.pl/files" // FIREFOX57 }, onload: function(response) { if(mode === 0) { $resultContainer.append($("
").append(response.responseText).find("#fastFilesArea")); } else { $resultContainer.append($("
").append(response.responseText).find("#downloadFilesArea")); } $resultContainer.find("input[type=checkbox]").remove(); cb($resultContainer,hashes.length); } }); } }); }; this.getLinks = function(urls,cb) { // cb(downloadlinks) if(this.settings.downloadmode == "direct") { return this._getDirectLinks(urls,cb); } else { return this._getServerLinks(urls,cb); } }; this._getDirectLinks = function(urls,cb) { // Get Direct download links this.getResults(urls,async function($node,N) { if(!$node || N < 1) { cb(false); return; } var text = $node.html(); /* 16-08-2014 20:22 Sciagnij */ var files = []; var re = /\(\d+)\-(\d+)\-(\d+) (\d+)\:(\d+)\<\/td\>(\s|\n)+\\y ? -1 : xy ? -1 : x 0) { progess.push(parseInt(data.StandardFiles[i].status,10)); percent += parseInt(data.StandardFiles[i].status,10); } } } } else { // Consecutive runs: Use the ids from first run for(var i = 0; i < data.StandardFiles.length; i++) { if(ids.indexOf(data.StandardFiles[i].id) == -1) continue; if(data.StandardFiles[i].status == "finish") { result.push(data.StandardFiles[i].download_url); progess.push(100); percent += 100; } else { runnning.push(data.StandardFiles[i]); if(parseInt(data.StandardFiles[i].status,10) > 0) { progess.push(parseInt(data.StandardFiles[i].status,10)); percent += parseInt(data.StandardFiles[i].status,10); } } } } /* Regarding caching in server mode: If you add a file, that is already on the server (or currently downloading), you will not be charged additional bandwith - therefore caching is not necessary at the moment. */ if(result.length === N) { setStatus((result.length===1?"One file":(result.length+" files"))+" downloaded to server",1); cb(result); } else { // Waiting percent = percent/N; //setStatus('Download '+result.length+'/'+N+' ('+Math.floor(percent)+'%)\n ',-1); var dotheight = N > 2?2:4; var h = 'Download '+result.length+'/'+N+' ('+Math.floor(percent)+'%)\n
'; for(var i = 0; i < N; i++) { if(progess[i]) { h += ''; } else { h += ''; } } h += '
'; setStatus(h); showOnlyStatus(); window.setTimeout(function() { self._getProgress(cb,$node,N,ids); },self.updateDownloadProgressInterval); } } }); }; })(), }; var debridprovider = Object.keys(multi); var currentdebrid = await GM.getValue("currentdebrid",debridprovider[0]); for(var key in multi) { await multi[key].init(); if(key == currentdebrid) { await multi[key].loadSettings(); continue; } /* GM.registerMenuCommand(s_myname+" - Switch to "+multi[key].name, (function(key) { return async function() { if(!confirm(s_myname+"\n\nSet multi-download provider:\n"+multi[key].name)) return; await GM.setValue("currentdebrid",key); currentdebrid = key; document.location.reload(); }})(key) ); */ } /* GM.registerMenuCommand(s_myname+" - Delete cached links", async function() { if(!confirm(s_myname+"\n\nReally delete cached links?")) return; await GM.setValue("cachedDownloadLinks","{}") alert(s_myname+"\n\nCache is empty!"); }); GM.registerMenuCommand(s_myname+" - Restore dialogs and warnings", async function() { if(!confirm(s_myname+"\n\nReally restore all dialogs and warnings?")) return; await GM.setValue("dialogs","[]"); alert(s_myname+"\n\nDialogs and warnings restored"); }); */ function round(f,p) { // Round f to p places after the comma return parseFloat(parseFloat(f).toFixed(p)); } function popUp(id,cb_close,thisArg,doNotCloseOnOutsideClick) { // Remove window scrolling $(document.body).css("overflow","hidden"); var zi = getNextZIndex(); var id = id?id:("popup"+(new Date).getTime()); var $par = $('
').attr("id",id).appendTo(document.body); var $background = $('
').appendTo($par); var $div = $('
').css('maxHeight',window.innerHeight-100).css('maxWidth',window.innerWidth-200).appendTo($par); var close = function() { $par.remove(); if(cb_close) cb_close.call(thisArg); // Restore scrolling $(document.body).css("overflow","initial"); }; if(!doNotCloseOnOutsideClick) { $background.click(close); } return {"node": $div, "close": close}; } function configForm($form,c,s,formid) { for(var key in c) { if(key.endsWith("desc") || key.endsWith("range") || key.endsWith("quest") || key.endsWith("prefix") || key.endsWith("suffix")) { continue; } var $p = $("

").appendTo($form); if(c[key+"_quest"]) { $p.append(c[key+"_quest"]); } else { $p.append(key); } $p.append("
"); if(c[key+"_prefix"]) { $p.append(c[key+"_prefix"]+" "); } if(c[key] == 'int') { // Int var $input = $('').addClass("form_"+formid).data("key",key).data("parse","int").val(s[key]).appendTo($p); if(c[key+"_range"]) { $input.prop("min",c[key+"_range"][0]); $input.prop("max",c[key+"_range"][2]); $input.prop("title",c[key+"_range"][0]+" - "+c[key+"_range"][2]); } } else if(c[key] == 'string') { // String $('').addClass("form_"+formid).data("key",key).data("parse","string").val(s[key]).appendTo($p); } else if(c[key] == 'bool') { // Bool var $select = $('').addClass("form_"+formid).data("key",key).data("parse","bool").appendTo($p); var $optionYes = $('').val("true").appendTo($select); if(c[key+"_desc"]) { $optionYes.html(c[key+"_desc"][0]); } else { $optionYes.html("Yes"); } if(s[key]) { $optionYes[0].selected = true; } var $optionNo = $('').val("false").appendTo($select); if(c[key+"_desc"]) { $optionNo.html(c[key+"_desc"][1]); } else { $optionNo.html("No"); } if(!s[key]) { $optionNo[0].selected = true; } } else if(Array.isArray(c[key][0])) { // Nested array for(var j = 0; j < c[key].length; j++) { if(c[key+"_desc"] && !Array.isArray(c[key+"_desc"][j])) { $p.append(c[key+"_desc"][j]+": "); } var $select = $('').addClass("form_"+formid).data("key",key).data("index",j).appendTo($p); for(var i = 0; i < c[key][j].length; i++) { var $option = $('').val(c[key][j][i]).appendTo($select); if(c[key+"_desc"] && Array.isArray(c[key+"_desc"][0])) { $option.html(c[key+"_desc"][j][i]); } else { $option.html(c[key][j][i]); } if(s[key][j] == c[key][j][i]) $option[0].selected = true; } $p.append("
"); } } else { // Array var $select = $('').addClass("form_"+formid).data("key",key).appendTo($p); for(var i = 0; i < c[key].length; i++) { var $option = $('').val(c[key][i]).appendTo($select); if(c[key+"_desc"]) { $option.html(c[key+"_desc"][i]); } else { $option.html(c[key][i]); } if(s[key] == c[key][i]) $option[0].selected = true; } } if(c[key+"_suffix"]) { $p.append(" "+c[key+"_suffix"]); } } } async function saveSettings(ev) { var $body = ev.data; var $form = $body.find(".form"); // Save preferred hoster: currentdebrid = $form.find('.debridhoster').val(); // Save options: var newsettings = { 'general' : {} }; for(var key in multi) { newsettings[key] = {}; } $form.find('*[class^=form_]').each(function() { var $this = $(this); var namespace = $this.prop("class").split("_",2)[1]; var key = $this.data("key"); var index = $this.data("index"); var value = $this.val(); var parse = $this.data("parse"); if(typeof index != 'undefined') { // Nested Array if(!(key in newsettings[namespace]) || !Array.isArray(newsettings[namespace][key])) { newsettings[namespace][key] = []; } newsettings[namespace][key][index] = value; } else { // Normal if(parse == 'int') { value = parseInt(value,10); } else if(parse == 'bool') { value = (value == "true"); } newsettings[namespace][key] = value; } }); await GM.setValue("setup",true); await GM.setValue("currentdebrid",currentdebrid); await GM.setValue("settings",JSON.stringify(newsettings.general)); for(var key in multi) { await GM.setValue(key+"_settings",JSON.stringify(newsettings[key])); } alert(s_myname+"\n\nSettings were successfully saved!"); document.location.reload(); } async function aboutMe() { var popup = popUp("multiochhelper_about",null,null,true); var $popup = popup.node; var $frame = $('