Last active
March 2, 2016 14:53
-
-
Save tony01111299/68e0b70fa4758b3bced3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Test</title> | |
<script type="text/javascript"> | |
/*function RemoveUrlParameter(url, parameters) { | |
var substr1 = url.split("?"); | |
for(var i = 2; i < substr1.length; i++) | |
substr1[1] += '?' + substr1[i]; | |
if(substr1.length > 2) | |
substr1.splice(2, substr1.length - 2); | |
var substr2 = substr1[1].split("&"); | |
for(var i = 0; i < substr2.length; i++) | |
if(substr2[i].match(parameters+"=") != null && substr2[i][parameters.length] == '=') | |
{ | |
substr2.splice(i, 1); | |
i--; | |
} | |
for(var i = 1; i < substr2.length; i++) | |
substr2[0] += "&" + substr2[i]; | |
return substr1[0] + "?" + substr2[0] | |
}*/ | |
function RemoveUrlParameter(url, rmParameters) | |
{ | |
// http://exhentai.org/?a=3&b=4... | |
// ['a'] | |
// => http://exhentai.org/?b=4... | |
var [umatch, upath, uparameter] = url.match(/([^\?]*)\?(.*)/); | |
var uparas = uparameter.split('&'); | |
var resParas = uparas.filter((p) => | |
{ | |
return rmParameters.every((rp) => | |
{ | |
return p.indexOf(rp + '=') < 0; | |
}); | |
}); | |
if (resParas.length > 0) | |
{ | |
return `${upath}?${resParas.join('&')}`; | |
} | |
else | |
{ | |
return upath; | |
} | |
} | |
var text_url = "http://www.this.is.a.webpage/?page=3&f_doujinshi=on&f_manga=on&f_artistcg=on&f_gamecg=on&f_western=on&f_non-h=on&f_imageset=on&f_cosplay=on&f_asianporn=on&f_misc=on&f_search=guro&f_apply=Apply+Filter"; | |
</script> | |
<style type="text/css"> | |
.texts{ | |
width: 90%; | |
} | |
body,button{ | |
font-size: 24px; | |
} | |
input{ | |
font-size: 20px; | |
} | |
</style> | |
</head> | |
<body> | |
Url: <input type="text" class="texts" id="url"><br> | |
Parameters: <input type="text" class="texts" id="parameters"><br> | |
Output: <input type="text" class="texts" id="output"><br><br> | |
<button onclick="getElementById('output').value = RemoveUrlParameter(getElementById('url').value, eval(getElementById('parameters').value))">Test</button> | |
<script type="text/javascript"> | |
document.getElementById("url").value = text_url; | |
document.getElementById("parameters").value = "['page']"; | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment