Skip to content

Commit ad60e0d

Browse files
committed
Updated
1 parent 5e32678 commit ad60e0d

File tree

8 files changed

+147
-0
lines changed

8 files changed

+147
-0
lines changed

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,37 @@
11
# auto-scroll-extension
22
Chrome Extension to Automatically scrolls down when you visit a webpage
3+
4+
# Auto Scroll Extension
5+
6+
Automatically scrolls down when you visit a webpage.
7+
8+
## Description
9+
10+
The Auto Scroll Extension provides users with the convenience of automatically scrolling down webpages without manual interaction. It offers both full automation, where scrolling begins upon opening a webpage, and manual control, allowing users to start and stop scrolling as desired.
11+
12+
## Features
13+
14+
- **Full Automation**: Automatically scrolls down webpages upon opening.
15+
- **Manual Control**: Users can start and stop scrolling manually using the extension's settings panel.
16+
- **Customizable Settings**: Options for adjusting scroll speed and behavior.
17+
18+
## Installation
19+
20+
1. Clone or download the repository to your local machine.
21+
2. Navigate to `chrome://extensions/` in your Chrome browser.
22+
3. Enable "Developer mode" in the top right corner.
23+
4. Click on "Load unpacked" and select the folder containing the extension files.
24+
25+
## Usage
26+
27+
- **Full Automation**: Click on the extension icon to activate automatic scrolling.
28+
- **Manual Control**: Click on the extension icon to access the settings panel, where you can start and stop scrolling manually.
29+
30+
31+
## Contributing
32+
33+
Contributions are welcome! If you have any suggestions, bug reports, or feature requests, please open an issue or submit a pull request on GitHub.
34+
35+
## License
36+
37+
This project is licensed under the [MIT License](LICENSE).

background.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Execute the content script when the extension is loaded
2+
chrome.runtime.onInstalled.addListener(function() {
3+
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
4+
chrome.tabs.executeScript(tabs[0].id, { file: 'content.js' });
5+
});
6+
});
7+

content.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Define the scrolling function with optional manual control
2+
function autoScrollWithManualControl() {
3+
// Set the scroll speed (adjust as needed)
4+
const scrollSpeed = 2; // pixels per frame
5+
6+
// Function to scroll down
7+
function scroll() {
8+
window.scrollBy(0, scrollSpeed);
9+
if (window.innerHeight + window.scrollY < document.body.offsetHeight) {
10+
intervalId = requestAnimationFrame(scroll);
11+
}
12+
}
13+
14+
// Start scrolling
15+
intervalId = requestAnimationFrame(scroll);
16+
}
17+
18+
// Check if manual mode is enabled
19+
chrome.storage.sync.get('manualMode', function(data) {
20+
if (data.manualMode) {
21+
// Listen for messages from the extension popup
22+
chrome.runtime.onMessage.addListener(function(message) {
23+
if (message.action === 'start') {
24+
autoScrollWithManualControl();
25+
} else if (message.action === 'stop') {
26+
cancelAnimationFrame(intervalId);
27+
}
28+
});
29+
} else {
30+
// Start scrolling automatically
31+
autoScrollWithManualControl();
32+
}
33+
});
34+

icon16.png

378 Bytes
Loading

icon48.png

989 Bytes
Loading

manifest.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"manifest_version": 2,
3+
"name": "Auto Scroll Extension",
4+
"version": "1.0",
5+
"description": "Automatically scrolls down when you visit a webpage.",
6+
"permissions": ["activeTab", "storage"],
7+
"icons": {
8+
"16": "icon16.png",
9+
"48": "icon48.png"
10+
},
11+
"background": {
12+
"scripts": ["background.js"],
13+
"persistent": false
14+
},
15+
"content_scripts": [
16+
{
17+
"matches": ["<all_urls>"],
18+
"js": ["content.js"]
19+
}
20+
],
21+
"browser_action": {
22+
"default_popup": "popup.html",
23+
"default_icon": {
24+
"16": "icon16.png",
25+
"48": "icon48.png"
26+
}
27+
}
28+
}
29+

popup.html

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>Auto Scroll Extension</title>
7+
<style>
8+
button {
9+
margin: 5px;
10+
}
11+
</style>
12+
</head>
13+
<body>
14+
<button id="startBtn">Start Automation</button>
15+
<button id="stopBtn">Stop Automation</button>
16+
17+
<script src="popup.js"></script>
18+
</body>
19+
</html>

popup.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Get the start and stop buttons
2+
const startBtn = document.getElementById('startBtn');
3+
const stopBtn = document.getElementById('stopBtn');
4+
5+
// Add event listeners to the buttons
6+
startBtn.addEventListener('click', startAutomation);
7+
stopBtn.addEventListener('click', stopAutomation);
8+
9+
let intervalId;
10+
11+
// Function to start automation
12+
function startAutomation() {
13+
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
14+
chrome.tabs.executeScript(tabs[0].id, { file: 'content.js' });
15+
});
16+
}
17+
18+
// Function to stop automation
19+
function stopAutomation() {
20+
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
21+
chrome.tabs.executeScript(tabs[0].id, { code: 'clearInterval(' + intervalId + ');' });
22+
});
23+
}

0 commit comments

Comments
 (0)