// ==UserScript== // @name Multi-OCH Helper Highlight links // @namespace cuzi // @license MIT // @copyright 2014, cuzi (https://openuserjs.org/users/cuzi) // @description nopremium.pl and premiumize.me. Highlight one-click-hoster links and include Multi-OCH Helper button // @homepageURL https://openuserjs.org/scripts/cuzi/Multi-OCH_Helper_Highlight_links // @icon https://greasyfork.org/system/screenshots/screenshots/000/003/478/original/icon_ampel.png // @include * // @exclude *.yahoo.* // @exclude *.google.* // @exclude *.youtube.* // @exclude *.bing.com* // @exclude *duckduckgo.com* // @exclude *bandcamp.com* // @exclude *.tumblr.com* // @version 10.12 // @grant GM.setValue // @grant GM.getValue // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js // @require https://openuserjs.org/src/libs/cuzi/OCH_List.js // @downloadURL none // ==/UserScript== /* globals getOCH, GM, $, alert, NodeFilter */ (async function () { 'use strict' const MAXTEXTNODES = 10000 const scriptName = 'Multi-OCH Helper Highlight links' const mainScriptName = 'Multi-OCH Helper' const syncHostersHost = 'https://cvzi.github.io/' const syncHostersUrl = syncHostersHost + 'Userscripts/index.html?link=sync' const ignoreList = [['some.love.txt', 30]] const chrome = ~navigator.userAgent.indexOf('Chrome') const $J = $.noConflict(true) const config = { mouseOverDelay: 700, frameWidth: '170px', frameHeight: '200px', colorHosterAvailableBG: 'green', colorHosterAvailableFG: 'white', colorHosterUnavailableBG: 'rgba(255,0,0,0.5)', colorHosterUnavailableFG: 'white', colorLinkOfflineBG: 'rgba(255,0,0,0.5)', colorLinkOfflineFG: 'silver', maxRequestsPerPage: 2, updateHosterStatusInterval: 24 * 7 // weekly update } // These hosters are supported by but have a X-Frame-Options enabled or simply do not work without javascript. const frameHosterWhitelist = [ ] const multi = { 'nopremium.pl': new function () { const self = this this.key = 'nopremium.pl' this.name = 'NoPremium.pl' this.homepage = 'https://www.nopremium.pl/' const mapHosterName = (name) => name.replace('-', '') this.updateStatusURL = 'https://www.nopremium.pl/' this.updateStatusURLpattern = /https?:\/\/www\.nopremium\.pl.*/ this.status = {} this.init = async function () { self.lastUpdate = new Date(await GM.getValue(self.key + '_status_time', 0)) self.status = JSON.parse(await GM.getValue(self.key + '_status', '{}')) } 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 = {} $J('#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(scriptName + ': ' + self.name + ': Hosters (' + Object.keys(self.status).length + ') updated') } else { alert(scriptName + '\n\nError: wrong update URL') } } this.isOnline = (hostername) => hostername in self.status && self.status[hostername] }(), 'premiumize.me': new function () { const self = this 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.status = {} this.init = async function () { self.lastUpdate = new Date(await GM.getValue(self.key + '_status_time', 0)) self.status = JSON.parse(await GM.getValue(self.key + '_status', '{}')) } this.updateStatus = () => null // This works only with api key, which only the main script has this.isOnline = (hostername) => hostername in self.status && self.status[hostername] }() } function matchHoster (str) { // Return name of first hoster that matches, otherwise return false for (let i = 0; i < ignoreList.length; i++) { if (str.indexOf(...ignoreList[i]) !== -1) { return false } } for (const name in OCH) { for (var i = 0; i < OCH[name].pattern.length; i++) { if (OCH[name].pattern[i].test(str)) { return name } } } return false } // All suitable urls are saved in this array: const alllinks = [] function frameSrc (src) { // Prevent websites from busting the iframe by using a second "sandboxed" iframe // It's a kind of magic. const framesrc = 'data:text/html,' + encodeURIComponent(`