Skip to content

Commit

Permalink
add built folder
Browse files Browse the repository at this point in the history
  • Loading branch information
LaraMerdol committed May 19, 2023
1 parent bb4d24f commit c46a4aa
Show file tree
Hide file tree
Showing 23 changed files with 528 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
258 changes: 258 additions & 0 deletions build/Neutlan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,258 @@
NEUTLAN_URL = 'https://neutlan.com/api';
post = (endpoint, TOKEN = null, body = {}) => {
var headers = {
Accept: "application/json",
"Content-Type": "application/json"
}

if (TOKEN != null) {
headers['Authorization'] = 'Token ' + TOKEN;
}

return fetch(this.NEUTLAN_URL + endpoint, {
method: "POST",
headers: headers,
body: JSON.stringify(body)
})
}
let paragraph = "";
let sentencesArray = [];
var style = document.createElement('style');

// Set the style content to include the styles for the .span_neutlan class
style.textContent = `
.span_neutlan {
color: #0000ff00;
font-size: xx-large;
vertical-align: middle;
line-height: initial;
}`;

// Add the style element to the document head
document.head.appendChild(style);
let styledTextElement = document.createElement('div');
styledTextElement.classList.add('neutlan_div');
let size = 'large';
let font = 'arial, sans-serif';
// Toke taken fromthe choreme storage you always loged in if you not delete chorome storage and logout
chrome.storage.local.get(['token', 'activated', 'color'], function (result) {
let token = result.token;
let checked = result.activated;
let color = result.color;
localStorage.setItem("token", token);
localStorage.setItem("activated", checked)
localStorage.setItem("color", color?color:"#00ff00")
});
// In your background page script

chrome.storage.onChanged.addListener(function (changes, namespace) {
for (var key in changes) {
if (key == 'activated') {
localStorage.setItem("activated", changes[key].newValue);
this.removeUnderline();
}
if (key == 'token') {
chrome.storage.local.get("token", function (result) {
if (result.token) {
window.location.reload()
}
})

}
if (key == 'color') {
chrome.storage.local.get("color", function (result) {
if (result.color) {
localStorage.setItem("color", result.color)
changeColor()
}
})

}
}
});


// Define function to remove underline
function removeUnderline() {
if (localStorage.getItem('activated') == "true") {
chrome.storage.local.get("token", function (result) {
if (result.token) {
let token = result.token;
const body = {
content: paragraph,
};
post('/model/process', token, body)
.then((response) => {
if (response.ok) {
return response.json().then((data) => {
sentencesArray = data.file_content;
styledTextElement.innerHTML = ""
updateContainer();
});

} else {
response.json().then((data) => {
});
}
})
.catch((error) => {
console.error("Error:", error);
});
}
})
this.updateContainer();
} else {
styledTextElement.innerHTML = ""
}

}
function changeColor() {
if (localStorage.getItem('activated') == "true") {
this.updateContainer();
} else {
styledTextElement.innerHTML = ""
}
}

updateContainer = () => {
styledTextElement.innerHTML = ""
const numberElement = document.createElement('div');
let count = 0;
numberElement.innerHTML = count;
sentencesArray.map(async (index, number) => {
const color = localStorage.getItem('color')
if (index.biased) {
count = 1 + count;
numberElement.innerHTML = count;
const spanElement = document.createElement('span');
spanElement.classList.add('span_neutlan');
spanElement.style.textDecoration = 'underline';
spanElement.style.textDecorationThickness = '2px';
spanElement.style.textDecorationColor = color;
spanElement.style.fontSize = size;
spanElement.style.lineHeight = size;
spanElement.style.fontFamily = font;
spanElement.innerHTML = index.content;
styledTextElement.appendChild(spanElement);
} else {
// otherwise, apply default styles
const spanElement = document.createElement('span');
spanElement.classList.add('span_neutlan');
spanElement.style.fontSize = size;
spanElement.style.fontFamily = font;
spanElement.style.lineHeight = size;
spanElement.innerHTML = index.content;
styledTextElement.appendChild(spanElement);
}
const format = `
position: absolute;
bottom: 4px;
right: 5px;
height: 30px;
pointer-events: none;
width: 30px;
font-size: 15px;
color: #fff;
border-radius: 50%;
display: flex;
background-color: #313265;
flex-wrap: nowrap;
justify-content: space-around;
align-items: center;
`.trim();
// Set the styles on the number element
numberElement.style.cssText = format;
styledTextElement.appendChild(numberElement);
});


};

let prevParagraph = "";
let intervalId = null;

myEventListener = (event) => {
chrome.storage.local.get("token", function (result) {
if (result.token) {
let token = result.token;
paragraph = event.target.value;
const textarea = event.target;
const styles = window.getComputedStyle(textarea);
styledTextElement.style.cssText = `
position: absolute;
inset: 0;
pointer-events: none;
height: ${styles.getPropertyValue('height')};
box-sizing: ${styles.getPropertyValue('box-sizing')};
width: ${styles.getPropertyValue('width')};
font-size: ${styles.getPropertyValue('font-size')};
line-height: ${styles.getPropertyValue('line-height')};
font-family: ${styles.getPropertyValue('font-family')};
padding-top: ${styles.getPropertyValue('padding-top')};
padding-right: ${styles.getPropertyValue('padding-right')};
padding-bottom: ${styles.getPropertyValue('padding-bottom')};
padding-left: ${styles.getPropertyValue('padding-left')};
margin-top: ${styles.getPropertyValue('margin-top')};
margin-right: ${styles.getPropertyValue('margin-right')};
margin-bottom: ${styles.getPropertyValue('margin-bottom')};
margin-left: ${styles.getPropertyValue('margin-left')};
z-index: 5;
overflow: hidden;
white-space: pre-wrap;
`;
size = window.getComputedStyle(textarea).getPropertyValue('font-size');
font = window.getComputedStyle(textarea).getPropertyValue('font-family');
parent = textarea.parentNode;
parent.appendChild(styledTextElement);
let isExecuted = false;

let checked;
if (localStorage.getItem("activated") == "true") {
checked = true
} else {
checked = false
}

clearInterval(intervalId);
intervalId = setInterval(() => {
paragraph = event.target.value;
if (paragraph !== prevParagraph && checked) {
styledTextElement.innerHTML = "";
const body = {
content: paragraph,
};
chrome.storage.local.get("token", function (result) {
if (result.token) {
let token = result.token;
post('/model/process', token, body)
.then((response) => {
if (response.ok) {
return response.json().then((data) => {
sentencesArray = data.file_content;
styledTextElement.innerHTML = ""
updateContainer();
prevParagraph = paragraph;
});

} else {
response.json().then((data) => {
});
}
})
.catch((error) => {
console.error("Error:", error);
});

}
}
)

}
}, 2000);
}
});
};

window.addEventListener("keyup", myEventListener);


42 changes: 42 additions & 0 deletions build/api-service.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
export class API {

static NEUTLAN_URL = 'https://neutlan.com/api';
//static NEUTLAN_URL_MODEL = 'https://neutlan.com/api';

static post(endpoint, TOKEN = null, body = {}) {
var headers = {
Accept: "application/json",
"Content-Type": "application/json"
}

if ( TOKEN != null ) {
headers['Authorization'] = 'Token ' + TOKEN;
}

return fetch(this.NEUTLAN_URL + endpoint, {
method: "POST",
headers: headers,
body: JSON.stringify(body)
})
}

static get(endpoint, TOKEN = null, body = {}) {
var headers = {
Accept: "application/json",
"Content-Type": "application/json"
}

if ( TOKEN != null) {
headers['Authorization'] = 'Token ' + TOKEN;
}

return fetch(this.NEUTLAN_URL + endpoint, {
method: "GET",
headers: headers,
body: JSON.stringify(body)
})
}

//Model

}
16 changes: 16 additions & 0 deletions build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"files": {
"main.css": "/static/css/main.3021c585.css",
"main.js": "/static/js/main.c02b49ea.js",
"static/js/787.28cb0dcd.chunk.js": "/static/js/787.28cb0dcd.chunk.js",
"static/media/neutlan_extension_header.png": "/static/media/neutlan_extension_header.c8532c5af573cb14a00a.png",
"index.html": "/index.html",
"main.3021c585.css.map": "/static/css/main.3021c585.css.map",
"main.c02b49ea.js.map": "/static/js/main.c02b49ea.js.map",
"787.28cb0dcd.chunk.js.map": "/static/js/787.28cb0dcd.chunk.js.map"
},
"entrypoints": [
"static/css/main.3021c585.css",
"static/js/main.c02b49ea.js"
]
}
Binary file added build/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions build/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>React App</title><script defer="defer" src="/static/js/main.c02b49ea.js"></script><link href="/static/css/main.3021c585.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
18 changes: 18 additions & 0 deletions build/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from "react";
import ReactDOM from "react-dom/client";
import "../src/App.css";
import App from "../src/App";
import reportWebVitals from "../src/reportWebVitals";

const root = ReactDOM.createRoot(document.getElementById("root"));

root.render(
<React.StrictMode>
<App />
</React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
Binary file added build/logo192.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 build/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions build/manifest _v2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"manifest_version": 2,
"name": "Neutlan: Chrome Extension For Text Analyzer",
"version": "1.0.1",
"description" :"Neutlan: Neutralize Language From Sexist Meanings",
"icons" : {
"512": "neutlan_logo.png"
},
"browser_action": {
"default_icon": "neutlan_logo.png",
"default_popup": "index.html",
"default_title": "Neutlan"
},
"permissions": [
"tabs",
"storage",
"cookies",
"*://*.google.com",
"https://*/",
"webRequest",
"scripting"
],
"host_permissions": [
"*://*.google.com/"
],
"content_scripts": [
{
"matches": ["<all_urls>"],
"js": ["Neutlan.js"]
}
],
"background": {
"scripts": ["Neutlan.js"],
"persistent": true
}
}

Loading

0 comments on commit c46a4aa

Please sign in to comment.