webm to mpv opener

Changes 4chan (fileText.webm) urls to a localhost url. The local server opens mpv to play the video.

Από την 14/01/2019. Δείτε την τελευταία έκδοση.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

You will need to install an extension such as Tampermonkey to install this script.

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

// ==UserScript==
// @name     webm to mpv opener
// @version     1.0.3
// @description     Changes 4chan (fileText.webm) urls to a localhost url. The local server opens mpv to play the video.         
// @namespace     https://greasyfork.org/users/3159
// @include     http*://boards.4chan*.org/*/*
// ==/UserScript==
a = document.getElementsByClassName('fileText');
for (i = 0; i < a.length; i++) {
	b = a[i].children[0];
	if (b.href.indexOf('.webm') > -1) {
		b.href = "http://127.0.0.1:4040?i=" + b;
		b.removeAttribute('target');
	}
}
/*
My mpv config text file (~/config/mpv/mpv.conf) has:
autofit-larger=100%x100%
loop=inf

Create a link to mpv:
sudo ln -s /Applications/mpv.app/Contents/MacOS/mpv /usr/bin/mpv

On OSX I used Platypus to change mpv_server.py (bellow) into an application.
Add the application to your login auto boot items, use python 2.7

import os
import subprocess, urlparse
import SimpleHTTPServer, SocketServer
PORT = 4040

class MyHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):

    def do_GET(self):
        parsedParams = urlparse.urlparse(self.path)
        parsed_query = urlparse.parse_qs(parsedParams.query)
        url = parsed_query['i'][0]
        self.send_response(204)
        
        os.system('pkill mpv') #only one
		
        subprocess.Popen(
	    ['mpv','-no-audio',url], #disabled audio
            stdout=subprocess.PIPE
        )

Handler = MyHandler
httpd = SocketServer.TCPServer(('', PORT), Handler)
print "serving at port ", PORT
httpd.serve_forever()

*/