Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick text Formatter #1417

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Quick Text Formatter/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
chrome.runtime.onMessage.addListener((message) => {
if (message.action === 'getSelection') {
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
chrome.tabs.sendMessage(tabs[0].id, { selection: window.getSelection().toString() });
});
}
});
14 changes: 14 additions & 0 deletions Quick Text Formatter/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"manifest_version": 3,
"name": "Quick Text Formatter",
"version": "1.0",
"description": "Format your text quickly and easily!",
"permissions": ["activeTab"],
"background": {
"scripts": ["background.js"]
},
"browser_action": {
"default_popup": "popup.html",
"default_title": "Quick Text Formatter"
}
}
20 changes: 20 additions & 0 deletions Quick Text Formatter/popup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Quick Text Formatter</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<h1>Quick Text Formatter</h1>
<button id="bold">Bold</button>
<button id="italic">Italic</button>
<button id="strikethrough">Strikethrough</button>
<button id="bullet-list">Bullet List</button>
</div>

<script src="script.js"></script>
</body>
</html>
15 changes: 15 additions & 0 deletions Quick Text Formatter/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const boldButton = document.getElementById('bold');
const italicButton = document.getElementById('italic');
const strikethroughButton = document.getElementById('strikethrough');
const bulletListButton = document.getElementById('bullet-list');

function formatText(format) {
chrome.tabs.executeScript(null, {
code: document.getSelection().toString().wrappedBy('${format}')
});
}

boldButton.addEventListener('click', () => formatText('<b></b>'));
italicButton.addEventListener('click', () => formatText('<i></i>'));
strikethroughButton.addEventListener('click', () => formatText('<s></s>'));
bulletListButton.addEventListener('click', () => formatText('<ul><li></li></ul>'));
39 changes: 39 additions & 0 deletions Quick Text Formatter/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
body {
font-family: sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f5f5f5;
}

.container {
background-color: #fff;
padding: 20px;
border-radius: 5px;
text-align: center;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
max-width: 300px; /* Ensure responsiveness on smaller screens */
}

h1 {
font-size: 20px;
margin-bottom: 10px;
color: #333;
}

button {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border: none;
border-radius: 3px;
cursor: pointer;
margin: 5px;
}

button:hover {
background-color: #3e8e41;
}
Loading