Skip to content

Commit c237320

Browse files
committed
API
1 parent f53b373 commit c237320

9 files changed

+1403
-2
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,8 @@
11
# Ignore Mac system files
22
.DS_store
3+
4+
.vercel
5+
#NEVER AGAIN
6+
.env
7+
8+
node_modules

docs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vercel

docs/api/index.js

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
var admin = require("firebase-admin");
3+
4+
if (!admin.apps.length) {
5+
admin.initializeApp({
6+
credential: admin.credential.cert({
7+
private_key: process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n'),
8+
client_email: process.env.FIREBASE_CLIENT_EMAIL,
9+
project_id: process.env.FIREBASE_PROJECT_ID
10+
}),
11+
databaseURL: process.env.FIREBASE_DATABASE_URL
12+
});
13+
14+
}
15+
16+
17+
18+
19+
module.exports = async (req, res) => {
20+
const db = admin.firestore()
21+
var pluginTotalBlockedref = await db.collection("plugin-blocked-count").doc("counter")
22+
var pluginTotalBlocked
23+
var count;
24+
if (req.query.count) {
25+
count = parseInt(req.query.count)
26+
pluginTotalBlocked = (await pluginTotalBlockedref.get()).data().count + count
27+
pluginTotalBlockedref.set({"count": parseInt(pluginTotalBlocked)})
28+
}
29+
else {
30+
pluginTotalBlocked = (await pluginTotalBlockedref.get()).data().count
31+
}
32+
res.json({
33+
count: pluginTotalBlocked
34+
})
35+
}

docs/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
<a href="http://hackernoon.com/signup" class="link linkItem">Subscribe</a>
5757
</div>
5858
<div id="repo" class="subtitle"></div>
59+
<div id="counter"></div>
5960
<div>
6061
<h1 class="title" id="mainTitle"></h1>
6162
<h2 class="subtitle">Open-Sourced by HackerNoon</h2>

docs/js/script.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ arrow.addEventListener('click', () => {
88

99
function pageLoad() {
1010
type('mainTitle', 'Free Internet Plugin', 50)
11-
repo()
11+
repoInfo()
1212
contribs()
1313
}
1414

@@ -36,7 +36,7 @@ function subPage() {
3636

3737
}
3838

39-
const repo = async () => {
39+
const repoInfo = async () => {
4040
await fetch('https://api.github.com/repos/hackernoon/Free-Internet-Plugin').then(response => response.json())
4141
.then(data => {
4242
document.getElementById("repo").innerHTML = `Stars: ${data.stargazers_count} - Forks: ${data.forks} - Watchers: ${data.subscribers_count}`
@@ -76,3 +76,11 @@ const contribs = async () => {
7676
}
7777
})
7878
}
79+
80+
const getTotalBlocked = async () => {
81+
await fetch('https://freeinternetplugin/api/').then(response => response.json())
82+
.then(data => {
83+
document.getElementById("counter").innerHTML = `blocked ${data.count} paywalls`
84+
})
85+
}
86+

0 commit comments

Comments
 (0)