Plextras.js
Plextras.js copied to clipboard
Alternative installation method
I'm sorry, this is not an issue, but more a suggestion.
There is a really easy installation method if you're running a plex proxy through nginx. Just add the following part to the location / block:
sub_filter '</head>' '<script language="javascript" src="//andrewiankidd.co.uk/ext/mimefix/?gitfile=Plextras.js"></script></head>';
sub_filter_once on;
This will insert the Plextras.js script before the </head>. The nice thing about this is its a server-side installation so Plextras.js is always there. You're not dependent on a local installation; it looks the same everywhere. The only exception being PMP.
@andrewiankidd Perhaps add this to the installation instructions?
this is the most interesting thing i've read this month! I'm wondering if i can insert a css file the same way!? but im getting a little ahead of myself. I can't get this to work. Am i missing something? this is my block:
server {
server_name plex.leram84.com;
include C:/nginx-1.11.5/config/leram84.com.conf;
include C:/nginx-1.11.5/config/auth-admin.conf;
error_page 400 401 402 403 404 https://leram84.com/error.php?error=$status;
location / {
#auth_request /auth-user;
proxy_pass http://127.0.0.1:32400;
include C:/nginx-1.11.5/config/proxy.conf;
sub_filter '</head>' '<script language="javascript" src="https://www.leram84.com/filerun/wl/?id=xxx"></script></head>';
sub_filter_once on;
}
}
Are you sure the script tag is in the sourcecode? The console (F12) might give some useful information.
I had the problem loading the raw js from Github, but it caused problems because the mime-type wasn't defined on Github's end. Loading it from @andrewiankidd website worked. I discovered this problem because the console gave me errors about it.
ok first of all, quite right. I was hosting it on an install of filerun and i guess it wasn't passing the filetype correctly.
Second of all... OMG IT WORKS!! :) I've had to deal w githubs labeling everything to txt in the past as well, if you want to host from them i suggest you check out https://github.com/rgrove/rawgit which basically handles this exact situation.
Third, and most importantly, it works w css too!! (which is great for me since i dont actually know js lol. I just threw this in to test sub_filter '</head>' '<link rel="stylesheet" type="text/css" href="//rawgit.com/leram84/layer.Cake/dev/CSS/garbage.css"></head>'; and it worked like a champ!
Now my only issue left is to figure out if there is any way to set the mime-type in nginx itself so i dont have to use rawgit at all because while its awesome and I'll definitely use it if theres no other option, there is one catch. It has a 24 hour propogation time after every edit, so would be much cleaner to be able to pull directly from github (this would also help A LOT with a couple other projects im working on)... any idea about that? I'm still kind of an nginx noob, so im sure theres plenty it's capable of that im not aware of (as you have just brilliantly pointed out w this thread :) )
In any case, THANKS for the tip!! Much appreciated!
The server you're pulling the data from needs to define the mime-types. I assume Github did it like that on purpose. You know Organizr. It fixes this by pulling for example your layer.Cake project files like this: ajax.php?a=show-file&file=https://raw.githubusercontent.com/leram84/layer.Cake/master/CSS/theBlur.css.
It basically functions like a proxy too. To see the function in action look here at showFile(): https://github.com/causefx/Organizr/blob/master/functions.php#L4152
If you have a domain yourself chances are big you don't have to do all this because your host arranged it.
yeah, was afraid of that. Im working on adding ombi to layercake now and theres no php so jamie can't use the same function that cause built for org. I was hoping this might be a work around. But actually, now that i think about it, this would't really help me there anyway since even if it was possible, it would mean that i had to define each stylesheet in nginx and thats not how layercake works. I guess my only options are finding something similar to showFile thats compatible w ombi, using a different host than github for the project, or just sticking with rawgit.
I'm not that familiar with either organizr or your project but you can just make 1 css file and do multiple @import url("base.css");
If the required CSS is dynamic you probably need javascript that loads the css depending on your requirements.
Hey Guys,
great suggestion on the alternate installation method, I'll add that.
As for the mimetype issues, you've guessed it right! Git doesnt supply the mimetype. I had this issue initially but have a tiny php script which grabs the file, adds a mimetype, and spits it back out.
example:
$output = file_get_contents("https://raw.githubusercontent.com/andrewiankidd/Plextras.js/master/Plextras.js");
header('Content-Type: application/javascript');
echo $output;