Skip to content

Commit

Permalink
Uploadin'
Browse files Browse the repository at this point in the history
  • Loading branch information
philedius committed May 23, 2020
1 parent 0d2f938 commit 941e8f9
Show file tree
Hide file tree
Showing 14 changed files with 5,490 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
dist/
packages/
14 changes: 14 additions & 0 deletions app/_locales/en/messages.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"appName": {
"message": "Letterblockd",
"description": "The name of the application"
},
"appShortName": {
"message": "lboxd user block",
"description": "The short_name (maximum of 12 characters recommended) is a short version of the app's name."
},
"appDescription": {
"message": "Block Letterboxd users that you don't want to see reviews from",
"description": "If you don't want to see content by some user on Letterboxd, then just add them to the list in the options. 馃"
}
}
Binary file added app/images/icon-128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/images/icon-16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 32 additions & 0 deletions app/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "__MSG_appName__",
"short_name": "__MSG_appShortName__",
"description": "__MSG_appDescription__",
"version": "0.0.0.1",
"manifest_version": 2,
"default_locale": "en",
"icons": {
"16": "images/icon-16.png",
"128": "images/icon-128.png"
},
"options_page": "pages/options.html",
"storage": {
"managed_schema": "schema.json"
},
"content_scripts": [
{
"matches": [
"http://letterboxd.com/*",
"https://letterboxd.com/*"
],
"css": [
"styles/contentscript.css"
],
"js": [
"scripts/contentscript.js"
],
"run_at": "document_start",
"all_frames": false
}
]
}
24 changes: 24 additions & 0 deletions app/pages/options.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Options</title>
<link rel="stylesheet" type="text/css" href="../styles/options.css">
</head>
<body>

<div id="options-container">
<h1>Blocked users</h1>
<p>Put one username per line. This should be the username that is in the URL when you view their profile.</p>
<p>For example: If the URL of their profile looks like this "letterboxd.com/sickhornybeaver",
then you would type "sickhornybeaver" in the text box below.</p>
<textarea id="block-list" rows="10"></textarea>
<div id="save-container">
<button id="save">Save changes</button>
<div id="status"></div>
</div>
</div>

<script src="../scripts/options.js"></script>
</body>
</html>
6 changes: 6 additions & 0 deletions app/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "object",
"blockedUsers": {
"type": "string"
}
}
5 changes: 5 additions & 0 deletions app/scripts/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
browser.runtime.onInstalled.addListener((details) => {
console.log('previousVersion', details.previousVersion)
})

console.log(`'Allo 'Allo! Event Page`)
40 changes: 40 additions & 0 deletions app/scripts/contentscript.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// identifier is a selector used to find the links
// list is an array of blocked users
// container is a selector to select which ancenstral element should be removed from the DOM
function remove(identifier, list, container = identifier) {
let els = document.querySelectorAll(`${identifier} a`);
if (els.length === 0) return;
let users = [...list];
for (let i = 0; i < els.length; i++) {
for (let j = users.length - 1; j >= 0; j--) {
if (els[i].getAttribute('href').indexOf('/' + users[j] + '/') !== -1) {
console.log('Removed content by', users[j]);
els[i].closest(container).remove();
users.splice(j, 1);
}
}
}
}

function removeAll() {
chrome.storage.sync.get({
blockedUsers: '[]',
}, items => {
if (items.blockedUsers.length > 0) {
let wait = [50, 100, 200, 500, 1000, 1500, 2500, 5000];
for (let i = 0; i < 8; i++) {
setTimeout(() => {
var users = JSON.parse(items.blockedUsers);
remove('.review-tile', users);
remove('.film-detail', users);
remove('.list', users);
remove('.poster-container', users);
remove('.people-shortlist', users, 'li');
remove('.person-summary', users, 'tr');
remove('.featured-person', users);
}, wait[i]);
}
}
});
}
document.addEventListener('DOMContentLoaded', removeAll);
33 changes: 33 additions & 0 deletions app/scripts/options.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function saveOptions() {
var userList = document.getElementById('block-list').value.split('\n');
for (let i = userList.length - 1; i >= 0; i--) {
if (!userList[i]) userList.splice(i, 1);
}
chrome.storage.sync.set({
blockedUsers: JSON.stringify(userList),
}, function() {
// Update status to let user know options were saved.
var status = document.getElementById('status');
status.textContent = 'Changes saved!';
setTimeout(function() {
status.textContent = '';
}, 2000);
});
}

function restoreOptions() {
// Use default value color = 'red' and likesColor = true.
chrome.storage.sync.get({
blockedUsers: '[]',
}, function(items) {
console.log(items);
console.log('options restored, bitch');
if (items.blockedUsers.length > 0) {
var formatted = JSON.parse(items.blockedUsers).join('\n');
document.getElementById('block-list').value = formatted;
}
});
}
document.addEventListener('DOMContentLoaded', restoreOptions);

document.getElementById('save').addEventListener('click', saveOptions);
Empty file added app/styles/contentscript.css
Empty file.
54 changes: 54 additions & 0 deletions app/styles/options.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#options-container {
display: flex;
max-width: 500px;
font-size: 20px;
line-height: 1.5;
color: #222;
margin: 2rem auto;
flex-direction: column;
padding: 1rem;
}

p:first-of-type {
margin-top: 0;
}

p {
text-align: justify;
}

textarea {
font-size: 20px;
font-family: "Segoe UI", Tahoma, sans-serif;
line-height: 1.5;
margin-top: 1.5rem;
border: 1px solid #ddd;
border-radius: 4px;
padding: .5rem 1rem;
}

button {
width: 165px;
font-size: 15px;
letter-spacing: 1px;
font-weight: 700;
line-height: 1.5;
margin: 1rem 0 0 0;
padding: .5rem;
border-radius: 100rem;
text-transform: uppercase;
background-color: #03cc8b;
border: none;
color: white;
}

#save-container {
display: flex;
margin-top: 1.75rem;
}

#status {
margin-top: 1.1rem;
margin-left: 2rem;
color: #222;
}
Loading

0 comments on commit 941e8f9

Please sign in to comment.