// ==UserScript== // @name KissLink // @namespace http://pyroglyph.co.uk/ // @version 1.0 // @description Gets direct video links from Kissanime.ru. // @author Pyroglyph // @match *kissanime.ru/Anime/* // @match *openload.co/embed/* // @grant none // @downloadURL none // ==/UserScript== window.onload = function() { 'use strict'; // If we are on a KissAnime page, if (~window.location.href.indexOf('kissanime.ru')) { // Get the currently selected Kiss server from the URL var currentServer = new URL(window.location.href).searchParams.get("s"); // If the current server is not OpenLoad, if (currentServer !== null) { // remove the server parameter and reload the page for the OpenLoad server. window.location = removeURLParameter(window.location, 's') + '&s=openload'; } // Switch window to the OpenLoad embed page. window.location = document.getElementById('divContentVideo').firstChild.getAttribute('src'); } // Otherwise, if we are on the OpenLoad embed page, if (~window.location.href.indexOf('openload.co/embed')) { // click() the page so videojs loads the direct url, document.elementFromPoint(0, 0).click(); // alert() the user of the direct link, alert('http://www.openload.co' + document.getElementById('olvideo_html5_api').getAttribute('src')); } }; // I swear I totally didn't just kang (and slightly improve) this from http://stackoverflow.com/questions/1634748 function removeURLParameter(url, parameter) { //prefer to use l.search if you have a location/link object var urlparts = (url + '').split('?'); if (urlparts.length >= 2) { var prefix = encodeURIComponent(parameter) + '='; var pars = urlparts[1].split(/[&;]/g); //reverse iteration as may be destructive for (var i = pars.length; i-- > 0;) { //idiom for string.startsWith if (pars[i].lastIndexOf(prefix, 0) !== -1) { pars.splice(i, 1); } } url = urlparts[0] + (pars.length > 0 ? '?' + pars.join('&') : ""); return url; } else return url; }