-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
73 additions
and
38 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
.env* | ||
/static/index.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const fs = require('fs'); | ||
const ad = require('./codefund'); | ||
|
||
ad().then(json => | ||
fs.writeFileSync(__dirname + '/static/index.json', JSON.stringify(json)) | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const fetch = require('node-fetch'); | ||
|
||
module.exports = buysellads; | ||
|
||
async function buySellAds(ip) { | ||
const adURL = 'https://srv.buysellads.com/ads/CVADL2JJ.json'; | ||
|
||
if (ip === '::1') { | ||
ip = '86.13.179.215'; | ||
} | ||
|
||
const request = await fetch(`${adURL}?forwardedip=${ip}&ignore=yes`); | ||
const data = await request.json(); | ||
|
||
const ads = data.ads.filter(ad => ad.active); | ||
const ad = ads[(ads.length * Math.random()) | 0]; | ||
|
||
const pixelsUrls = (ad.pixel || '').split('||'); | ||
const time = Math.round(Date.now() / 10000) | 0; | ||
const pixels = pixelsUrls.map(pixel => pixel.replace('[timestamp]', time)); | ||
|
||
const { title, description, statlink: url } = ad; | ||
|
||
return { | ||
url, | ||
description, | ||
title, | ||
pixels, | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const fetch = require('node-fetch'); | ||
|
||
module.exports = codefund; | ||
|
||
async function codefund() { | ||
const request = await fetch( | ||
'https://codefund.io/t/s/22e88dc3-30f2-451b-a14e-d257c1395ef1/details.json' | ||
); | ||
const data = await request.json(); | ||
|
||
const { title, description, link: url, pixel } = data; | ||
|
||
return { | ||
title, | ||
description, | ||
url, | ||
pixels: [pixel], | ||
}; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,19 @@ | ||
const fetch = require('node-fetch'); | ||
const cors = require('micro-cors')(); | ||
const sponsor = require('./static/index.json'); | ||
|
||
async function buySellAds(ip) { | ||
const adURL = 'https://srv.buysellads.com/ads/CVADL2JJ.json'; | ||
|
||
if (ip === '::1') { | ||
ip = '86.13.179.215'; | ||
} | ||
|
||
const request = await fetch(`${adURL}?forwardedip=${ip}&ignore=yes`); | ||
const data = await request.json(); | ||
|
||
console.log(`${adURL}?forwardedip=${ip}&ignore=yes`); | ||
|
||
const ads = data.ads.filter(ad => ad.active); | ||
const ad = ads[(ads.length * Math.random()) | 0]; | ||
|
||
const pixelsUrls = (ad.pixel || '').split('||'); | ||
const time = Math.round(Date.now() / 10000) | 0; | ||
const pixels = pixelsUrls.map(pixel => pixel.replace('[timestamp]', time)); | ||
|
||
const { title, description, statlink: url } = ad; | ||
|
||
return { | ||
url, | ||
description, | ||
title, | ||
pixels, | ||
}; | ||
} | ||
|
||
async function codesponsor() { | ||
return sponsor; | ||
} | ||
|
||
// const sponsor = require('./static/index.json'); | ||
|
||
const codefund = require('./codefund'); | ||
|
||
/** | ||
* Exports expects: | ||
* | ||
* { | ||
* url: String, // click through | ||
* description: String // displayed subtext | ||
* title: String, // link text | ||
* pixels: String[] // tracking images | ||
* } | ||
*/ | ||
module.exports = cors(async req => { | ||
const ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress; | ||
return await codesponsor(ip); | ||
return await codefund(ip); | ||
}); |
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