Implement support for some URL proxies
This commit is contained in:
parent
643d5b274c
commit
cb9043f36f
|
@ -34,7 +34,9 @@ var blacklist = ["pomf.", "mixtape.moe", "catgirlsare.sexy", "p.fuwafuwa.moe", "
|
|||
chrome.pageAction.onClicked.addListener(function(tab) {
|
||||
getCurrentTabUrl(function(url) {
|
||||
getBetterUrl(url, function(betterUrl) {
|
||||
var filename = betterUrl.substr(betterUrl.lastIndexOf("/"));
|
||||
filenameUrl = getProxiedUrl(betterUrl) || betterUrl;
|
||||
|
||||
var filename = filenameUrl.substr(filenameUrl.lastIndexOf("/"));
|
||||
filename = cleanExtension(filename);
|
||||
|
||||
if(filename.indexOf('.') == -1) {
|
||||
|
@ -195,6 +197,35 @@ chrome.webRequest.onBeforeSendHeaders.addListener(
|
|||
["blocking", "requestHeaders"]
|
||||
);
|
||||
|
||||
function getQueryObject(url) {
|
||||
var queryString = url.substring(url.indexOf('?') + 1);
|
||||
var split = queryString.split('&');
|
||||
|
||||
var query = {};
|
||||
for(var pair of split)
|
||||
{
|
||||
if(pair.indexOf('=') != -1) {
|
||||
var keyValue = /(.*)=(.*)/.exec(pair);
|
||||
query[keyValue[1]] = decodeURIComponent(keyValue[2]);
|
||||
} else {
|
||||
query[pair] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
function getProxiedUrl(url) {
|
||||
var query = getQueryObject(url);
|
||||
for(var key in query) {
|
||||
if(query[key] != null && query[key].indexOf('http') != -1) { //HACK: Use a regex
|
||||
return query[key];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function cleanExtension(url) {
|
||||
var trailingStrings = ["?", ":orig", ":large", ":small", ":thumb", ":medium"];
|
||||
|
||||
|
@ -228,6 +259,11 @@ function isGfycatUrl(url) {
|
|||
}
|
||||
|
||||
function isCoolUrl(url, callback) {
|
||||
var proxiedUrl = getProxiedUrl(url);
|
||||
if(proxiedUrl != null) {
|
||||
url = proxiedUrl;
|
||||
}
|
||||
|
||||
url = url.toLowerCase();
|
||||
|
||||
var extensionIndex = url.lastIndexOf('.');
|
||||
|
|
Loading…
Reference in New Issue