add cookie on web
This commit is contained in:
@@ -8,12 +8,16 @@ import * as pluginApi from "./test_web/api/plugins";
|
||||
import localizedFormat from "dayjs/plugin/localizedFormat";
|
||||
interface GlobalState {
|
||||
UserAgent?: string,
|
||||
Cookie?: string,
|
||||
}
|
||||
let globalState: GlobalState = {
|
||||
}
|
||||
|
||||
export const getUserAgent = () => {
|
||||
return globalState.UserAgent;
|
||||
export const getHeaders = () => {
|
||||
return {
|
||||
'User-Agent': globalState.UserAgent,
|
||||
'Cookie': globalState.Cookie,
|
||||
};
|
||||
};
|
||||
|
||||
const app = express();
|
||||
@@ -22,15 +26,29 @@ const host = "localhost";
|
||||
|
||||
const dirname = path.join(__dirname, "..");
|
||||
|
||||
app.use((req, res, next) => {
|
||||
globalState.UserAgent = req.headers["user-agent"];
|
||||
console.log('---------');
|
||||
console.log('default headers: ', globalState);
|
||||
console.log('---------');
|
||||
console.log();
|
||||
next();
|
||||
});
|
||||
app.use(bodyParser.json());
|
||||
app.use("/static", express.static(path.join(dirname, "test_web", "static")));
|
||||
app.use("/icons", express.static(path.join(dirname, "icons")));
|
||||
app.get("/all_plugins", (req, res) => {
|
||||
globalState.UserAgent = req.headers["user-agent"];
|
||||
console.log(globalState);
|
||||
const allPlugins = pluginApi.all_plugins();
|
||||
res.json(allPlugins);
|
||||
});
|
||||
app.post("/add_cookie", async (req, res) => {
|
||||
globalState.Cookie = req.body['cookie'];
|
||||
console.log('---------');
|
||||
console.log('default headers: ', globalState);
|
||||
console.log('---------');
|
||||
console.log();
|
||||
res.json({});
|
||||
});
|
||||
app.post("/filters", async (req, res) => {
|
||||
const filters = await pluginApi.getFilter(req.body['pluginRequirePath']);
|
||||
res.json(filters || []);
|
||||
|
||||
Reference in New Issue
Block a user