Last active
December 14, 2021 04:01
-
-
Save Brontojoris/ccff105d48ca1889f9dc734647a1284c to your computer and use it in GitHub Desktop.
Proxyman - Set a Content Type icon
This file contains 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
function onRequest(context, url, request) { | |
request.headers["Page"] = request.path; | |
return request; | |
} | |
function onResponse(context, url, request, response) { | |
if(response.statusCode !== 200){return response} | |
var contentIcon = "", | |
contentType = response.headers["Content-Type"]; | |
if(contentType){contentType = contentType.toLowerCase()}else{return response} | |
switch (contentType) { | |
case 'text/html; charset=utf-8': | |
case 'text/html;charset=utf-8': | |
case 'image/x-icon': | |
contentIcon = "📃" | |
break; | |
case 'application/x-javascript;charset=utf-8': | |
case 'application/javascript; charset=utf-8': | |
case 'application/javascript;charset=utf-8': | |
case 'application/json; charset=utf-8': | |
case 'application/json;charset=UTF-8': | |
case 'application/json;charset=utf-8': | |
case 'text/javascript;charset=UTF-8': | |
case 'application/x-javascript': | |
case 'application/javascript': | |
case 'text/css;charset=utf-8': | |
case 'application/json': | |
case 'application/xml': | |
case 'text/css': | |
contentIcon = "🧾" | |
break; | |
case 'image/svg+xml': | |
case 'image/png': | |
case 'image/jpeg': | |
case 'image/gif': | |
contentIcon = "🖼" | |
break; | |
case 'application/octet-stream': | |
contentIcon = "🔠" | |
break; | |
default: | |
contentIcon = "" | |
} | |
response.headers["Icon"] = " "+contentIcon; | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A script for Proxyman to display an icon for different content types.
Configure from: Proxyman > Scripting > Script List
To show these icons in the request window, open Proxyman > Tools > Custom Columns... and add a new one named "Icon"