Skip to content

Instantly share code, notes, and snippets.

@yingziwu
yingziwu / cors-deno.ts
Last active June 19, 2022 10:38
A CORS proxy write by deno
import { serve } from "https://deno.land/std/http/server.ts";
function error(code: number): Promise<Response> {
const response = new Response(null, {
status: code,
});
return Promise.resolve(response);
}
function options(): Promise<Response> {
(async () => {
const lotteryStatusUrl = 'https://bgme.me/@bgme/105206731005287886'; // 抽奖嘟文URL
const lotteryType = 'reblog'; // 抽奖类型:转发(reblog),收藏(favourite)
const candidateNumber = 5; // 候选中奖者人数
main();
async function main() {
const domain = document.location.hostname;
const token = JSON.parse(document.querySelector('#initial-state').text).meta.access_token;