Skip to content

Commit

Permalink
add chrome extension code and screenshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Wang committed Jul 18, 2019
1 parent d52d171 commit ce87ab9
Show file tree
Hide file tree
Showing 11 changed files with 161 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Minimal Twitter

Minimal Theme for the new Twitter UI!

![screenshot](./screenshot.png)
4 changes: 4 additions & 0 deletions chrome/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
chrome.browserAction.onClicked.addListener(function(activeTab) {
var newURL = "https://twitter.com/";
chrome.tabs.create({ url: newURL });
});
Binary file added chrome/images/MinimalTwitterIcon128.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/images/MinimalTwitterIcon16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/images/MinimalTwitterIcon32.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/images/MinimalTwitterIcon48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions chrome/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"name": "Minimal Twitter",
"short_name": "MinTwitter",
"description": "A minimal twitter theme for the new Twitter!",
"version": "1.0",
"manifest_version": 2,
"permissions": ["activeTab"],
"content_scripts": [
{
"css": ["minimal-twitter.css"],
"matches": ["https://twitter.com/*"]
},
{
"js": ["removePromoted.js"],
"matches": ["https://twitter.com/home"]
}
],
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_icon": {
"16": "images/MinimalTwitterIcon16.png",
"32": "images/MinimalTwitterIcon32.png",
"48": "images/MinimalTwitterIcon48.png",
"128": "images/MinimalTwitterIcon128.png"
}
},
"icons": {
"16": "images/MinimalTwitterIcon16.png",
"32": "images/MinimalTwitterIcon32.png",
"48": "images/MinimalTwitterIcon48.png",
"128": "images/MinimalTwitterIcon128.png"
},
"commands": {
"_execute_browser_action": {
"suggested_key": {
"default": "Ctrl+Shift+T",
"mac": "MacCtrl+Shift+T"
},
"description": "Opens Minimal Twitter"
}
}
}
61 changes: 61 additions & 0 deletions chrome/minimal-twitter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
header[role="banner"] {
align-items: start !important;
max-width: 100px !important;
}

main[role="main"] {
align-items: center !important;
}

@media all and (min-width: 1265px) {
main[role="main"] {
transform: translateX(-56px) !important;
}
}

div[title="Home"],
div[title="Explore"],
div[title="Notifications"],
div[title="Messages"],
div[title="Bookmarks"],
div[title="Lists"],
div[title="Profile"],
div[title="More"] {
display: none !important;
}

a[aria-label="Tweet"][role="button"] {
position: fixed;
right: 24px;
bottom: 24px;
max-width: 125px;
}

header[role="banner"] > div > div > div {
justify-content: center !important;
}

div[data-testid="sidebarColumn"] {
display: none !important;
}

/* --- Use this to make columns bigger on home page
div[data-testid="primaryColumn"] {
max-width: 750px !important;
}
div[data-testid="primaryColumn"] > div > div > div:nth-child(3) {
max-width: 750px !important;
}
div[data-testid="primaryColumn"]
> div
> div
> div:nth-child(2)
> div
> div:nth-child(2) {
max-width: 750px !important;
}
--- */
50 changes: 50 additions & 0 deletions chrome/removePromoted.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Removing promoted tweets
function scrollStop(callback) {
// Make sure a valid callback was provided
if (!callback || typeof callback !== "function") return;

// Setup scrolling variable
var isScrolling;

// Listen for scroll events
window.addEventListener(
"scroll",
function(event) {
// Clear our timeout throughout the scroll
window.clearTimeout(isScrolling);

// Set a timeout to run after scrolling ends
isScrolling = setTimeout(function() {
// Run the callback
callback();
}, 66);
},
false
);
}

function removeAds() {
var spanTags = document.getElementsByTagName("span");
var promotedText = "Promoted";
var found;

for (var i = 0; i < spanTags.length; i++) {
if (spanTags[i].textContent == promotedText) {
found = spanTags[i];
found.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.removeChild(
found.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode
.parentNode.parentNode
);
}
}

return;
}

scrollStop(function() {
removeAds();
});

setTimeout(() => {
removeAds();
}, 2000);
Binary file added screenshot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ce87ab9

Please sign in to comment.