├── .gitignore ├── static └── _headers ├── codefund.js ├── package.json ├── index.js └── buysellads.js /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .env* 3 | /static/index.json 4 | -------------------------------------------------------------------------------- /static/_headers: -------------------------------------------------------------------------------- 1 | /index.json 2 | Access-Control-Allow-Origin: * 3 | -------------------------------------------------------------------------------- /codefund.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | module.exports = codefund; 4 | 5 | async function codefund() { 6 | const request = await fetch( 7 | 'https://codefund.io/t/s/22e88dc3-30f2-451b-a14e-d257c1395ef1/details.json' 8 | ); 9 | const data = await request.json(); 10 | 11 | const { title, description, link: url, pixel } = data; 12 | 13 | return { 14 | title, 15 | description, 16 | url, 17 | pixels: [pixel], 18 | }; 19 | } 20 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "bsa", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "now": { 7 | "alias": "bsa", 8 | "dotenv": true 9 | }, 10 | "scripts": { 11 | "start": "micro", 12 | "build": "node build.js" 13 | }, 14 | "keywords": [], 15 | "author": "", 16 | "license": "ISC", 17 | "dependencies": { 18 | "micro": "^8.0.3", 19 | "micro-cors": "0.0.4", 20 | "node-fetch": "^1.7.2", 21 | "request": "^2.81.0" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const cors = require('micro-cors')(); 2 | // const sponsor = require('./static/index.json'); 3 | 4 | const codefund = require('./codefund'); 5 | 6 | /** 7 | * Exports expects: 8 | * 9 | * { 10 | * url: String, // click through 11 | * description: String // displayed subtext 12 | * title: String, // link text 13 | * pixels: String[] // tracking images 14 | * } 15 | */ 16 | module.exports = cors(async req => { 17 | const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; 18 | return await codefund(ip); 19 | }); 20 | -------------------------------------------------------------------------------- /buysellads.js: -------------------------------------------------------------------------------- 1 | const fetch = require('node-fetch'); 2 | 3 | module.exports = buysellads; 4 | 5 | async function buySellAds(ip) { 6 | const adURL = 'https://srv.buysellads.com/ads/CVADL2JJ.json'; 7 | 8 | if (ip === '::1') { 9 | ip = '86.13.179.215'; 10 | } 11 | 12 | const request = await fetch(`${adURL}?forwardedip=${ip}&ignore=yes`); 13 | const data = await request.json(); 14 | 15 | const ads = data.ads.filter(ad => ad.active); 16 | const ad = ads[(ads.length * Math.random()) | 0]; 17 | 18 | const pixelsUrls = (ad.pixel || '').split('||'); 19 | const time = Math.round(Date.now() / 10000) | 0; 20 | const pixels = pixelsUrls.map(pixel => pixel.replace('[timestamp]', time)); 21 | 22 | const { title, description, statlink: url } = ad; 23 | 24 | return { 25 | url, 26 | description, 27 | title, 28 | pixels, 29 | }; 30 | } 31 | --------------------------------------------------------------------------------