Skip to content

Commit

Permalink
Add facebook badge for top fan
Browse files Browse the repository at this point in the history
  • Loading branch information
rin2401 committed Jun 25, 2021
1 parent d98eccb commit ae1159e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
6 changes: 5 additions & 1 deletion r3mina/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "r3mina",
"version": "0.0.2",
"version": "0.0.3",
"description": "For anim3r",
"homepage_url": "http://r3mina.herokuapp.com",
"author": "rin2401",
Expand All @@ -14,6 +14,10 @@
{
"matches": ["*://anilist.co/*", "*://*.anilist.co/*"],
"js": ["r3mina.js"]
},
{
"matches": ["*://facebook.com/*", "*://*.facebook.com/*"],
"js": ["r3badge.js"]
}
]
}
37 changes: 37 additions & 0 deletions r3mina/r3badge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
FAN = ["lnphane"]


function add_badge() {
badge = `<div aria-label="Identity Badges" role="button" tabindex="0">
<div>
<span style="color: #f2c2cf">🐹 Phan siêu cứng</span>
</div>
</div>`


// <img height="12" alt="" style="color: #f2c2cf" referrerpolicy="origin-when-cross-origin" src="https://static.xx.fbcdn.net/rsrc.php/v3/ya/r/mTNr7Jn2-Jk.png">

posts = document.querySelectorAll('[role="article"]')
for (post of posts) {
comments = post.querySelectorAll('li div[role="article"]')
for (comment of comments) {
user = comment.querySelectorAll('a')[1]
is_fan = FAN.some(v => user.href.includes(v))

if (!is_fan) continue

parent = user.parentElement.parentElement

badges = parent.querySelectorAll('[role="button"]')

if (!badges.length) {
parent.innerHTML = badge + parent.innerHTML
}

console.log(user.href)
}
}
}

add_badge()
window.addEventListener("scroll", add_badge);

0 comments on commit ae1159e

Please sign in to comment.