Skip to content

Commit

Permalink
biroliro 0.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
surak committed Mar 29, 2021
0 parents commit 946b799
Show file tree
Hide file tree
Showing 15 changed files with 184 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Dando nome aos bois

## Overview

It does exactly what you expect. It changes the brazilian president's name with adjectives.

## Getting Started

### Download Google Chrome
Download Google Chrome if you haven't already! You can download the latest version [here](https://www.google.com/chrome/browser/desktop/). For this hackpack, you'll need Chrome Version 40 or newer. In order to figure out which version you have, go to [chrome://version/](chrome://version/) in the Omnibar, and look at the top line. You should see something like

```
Google Chrome 48.0.2564.109 (Official Build) (64-bit)
```

Don't worry if it's not exactly the same. As long as the major number (before the decimal point) is greater than 40, you're set!

### Load Starter Code
Chrome usually ships extensions as `.crx` files (similar to `.zip` files), which is great for distribution, but not so great for developing. Instead, we'll tell Chrome to treat the starter code folder as an extension.

We need to enable Chrome Developer Settings in order to build our chrome extension.

In order to do this:

1. Navigate to [chrome://extensions](chrome://extensions) in your browser.
2. Ensure that the **Developer mode** checkbox in the top right-hand corner is checked.
3. Click **Load unpacked extension...** to pop up a file-selection dialog.
4. Navigate to the directory in which your extension files live, and select it.

You should now see a screen that looks like the below:

<a href="Loading Starter Code"><img src="https://i.imgur.com/qPhFaI0.png" height="500" ></a>


Note that the **Developer mode** checkbox is checked, and the extension is enabled.

Additionally, pay close attention to the **Reload** link.

**By default, Chrome will _not_ reload your extension automatically if you update your code. Thus, if you want to test your extension, you _must_ reload the extension before testing. Otherwise, your changes will _not_ be present in the active extension.** Basically, every time you make a change to your code that you want to test live in Chrome, make sure to reload the extension using that **Reload** button.
Binary file added icons/.DS_Store
Binary file not shown.
Binary file added icons/Biro-white-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 icons/Biro-white-16.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 icons/Biro-white-19.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 icons/Biro-white-190.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 icons/Biro-white-32.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 icons/Biro-white-48.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 icons/Biro-white-64.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 icons/Biro-white-96.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 icons/BiroCoverPhoto.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* File: manifest.json
* -------------------
* A manifest file (like this one) is used to
* give Chrome information about your extension.
*
* You shouldn't need to change anything in this file
* unless you're doing extensions.
*
* For more details, check out the documentation:
* https://developer.chrome.com/extensions/manifest
*/

{
// Required
"manifest_version": 2,
"name": "Biroliro",
"version": "0.0.1",

// Recommended
"description": "Dando nome aos bois",
"icons": {
"16": "icons/Biro-white-16.png",
"32": "icons/Biro-white-32.png",
"48": "icons/Biro-white-48.png",
"64": "icons/Biro-white-64.png",
"96": "icons/Biro-white-96.png",
"128": "icons/Biro-white-128.png"
},

// Optional
"homepage_url": "https://www.brasil.gov.br/",

// Put any additional permissions your applications needs here.
// For a list of possibilities, see
// https://developer.chrome.com/extensions/declare_permissions
"permissions": [
"storage" // Allows access to chrome.storage API
],

// Probably will not need to be modified unless you *really*
// know what you're doing
"browser_action": {
"default_icon": "icons/Biro-white-19.png",
"default_title": "Nome aos bois",
"default_popup": "src/popup.html"
},
"content_scripts": [
{
"matches": [
"*://*/*"
],
"js": [
"/src/content.js"
],
"run_at": "document_end"
}
]
}
31 changes: 31 additions & 0 deletions src/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/* File: content.js
* ---------------
* Hello! You'll be making most of your changes
* in this file. At a high level, this code replaces
* the substring "cal" with the string "butt" on web pages.
*
* This file contains javascript code that is executed
* everytime a webpage loads over HTTP or HTTPS.
*/

var elements = document.getElementsByTagName('*');

const biro = ["Genocida", "Biroliro", "Bolso", "Minionmaster", "Filho da Puta", "Assassino", "Bozo", "Escroto", "Bananinha", "Não-é-coveiro", "Incompetente", "Sacana"]
const random = Math.floor(Math.random() * biro.length);

for (var i = 0; i < elements.length; i++) {
var element = elements[i];

for (var j = 0; j < element.childNodes.length; j++) {
var node = element.childNodes[j];

if (node.nodeType === 3) {
var text = node.nodeValue;
var replacedText = text.replace(/Bolsonaro/gi, biro[random]); // replaces "cal," "Cal", etc. with "butt"

if (replacedText !== text) {
element.replaceChild(document.createTextNode(replacedText), node);
}
}
}
}
36 changes: 36 additions & 0 deletions src/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<!--
File: popup.html
=========================
This file contains the HTML visible in the browser action,
which is the window that pops up when you click the icon
in the upper right corner of the Chrome window. Update this
HTML file to change the layout of the content if you'd like!
Currently, it is the Biro banner.
The file doesn't need to be updated for the hackpack, but
making it look stylish can be a cool extension.
-->

<!DOCTYPE html>
<html>

<style>
body {
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
font-size: 100%;
position: relative;
vertical-align:middle;
background-image: url(/icons/BiroCoverPhoto.jpg);
background-size: 100% 100%;
min-width: 600px;
min-height: 200px;
*/
}
</style >

<body>

<script src="popup.js" ></script>

</body>
</html>
20 changes: 20 additions & 0 deletions src/popup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/* File: popup.js
* -----------------------
* This javascript file restores settings when the DOM loads.
* You shouldn't have to change this file unless you also
* change the corresponding popup.html file.
*/


document.addEventListener('DOMContentLoaded', function () {
var links = document.getElementsByTagName("a");
for (var i = 0; i < links.length; i++) {
(function () {
var ln = links[i];
var location = ln.href;
ln.onclick = function () {
chrome.tabs.create({active: true, url: location});
};
})();
}
});

0 comments on commit 946b799

Please sign in to comment.