Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jpablobr committed Dec 30, 2013
0 parents commit 39761db
Show file tree
Hide file tree
Showing 9 changed files with 447 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
@@ -0,0 +1,36 @@
# Simple Auto Scroll

### 1. What is it?

A speed-customizable auto-scroll Google Chrome extension.

### 2. Why?

A lot of times I find myself reading long
[texfiles](http://www.textfiles.com/), and after a while, I kind of
wish I could just read them as if they were a movie. I've tried with
the mouse (middle click) thingy, but it's just not practical and
adjusting the speed is very tricky - not to mention that a lot of
times it's just too fast.

## 3. Features

This extension allows you to easily change the auto-scroll speed and
save it in three different modes; slow, medium and fast. A single
click will stop the auto-scrolling.

### 3. Installing

**Option 1** just install it from the [chrome web store](https://chrome.google.com/webstore/detail/dccjkemhmffnljlnnoffljpkhkfpldff)

**Option 2** – install it from source:

* clone/download this repo,
* open Chrome and go to `chrome://chrome/extensions/`,
* enable "Developer mode",
* click "Load unpacked extension",
* select the `extension` folder in this repo.

### 4. Compatibility

It works on all Chrome distribution channels: Stable, Beta and Dev.
8 changes: 8 additions & 0 deletions background.html
@@ -0,0 +1,8 @@
<html>
<head>
<title>Auto Scroll</title>
</head>
<body >
<script src="js/background.js"></script>
</body>
</html>
98 changes: 98 additions & 0 deletions css/background.css
@@ -0,0 +1,98 @@
body {
background:#fff;
font-size: 13.4px;
font-family: Verdana, sans-serif;
color: #333333;
margin: 0;
}

a {
text-decoration: none; color: #333333;
}

td {
padding-right: 15px;
}

button {
font-weight:bold;
border:1px solid #ccc;
background:#f6f6f6;
color:#777;
text-shadow:1px 1px 0 white;
padding:5px 10px;
border-radius:5px;
background-image:-webkit-gradient(linear,left top,left bottom,from(white),to(#EFEFEF));
-webkit-transition: all 0.15s ease-out;
}

button:hover {
color:#555;
box-shadow:0 0 3px #999;
}

input[type=text] {
color: #010101;
background-color: transparent;
padding: 3px;
outline: none;
text-align: center;
border: 1px solid #bbb;
width: 38px;
margin-right:10px;
-webkit-border-radius: 4px;
-webkit-box-shadow: #CCC 0px 0px 2px;
}

textarea {
padding:10px;
width: 770px;
border: 1px solid #DDD;
-webkit-border-radius: 8px;
color: #777;
}

#page {
margin:0 auto 10px;
width: 800px;
text-align: left;
-webkit-border-radius: 20px;
-webkit-box-shadow: #ddd -2px 2px 10px;
}

#title {
margin: 20px;
font-size: 40px;
padding-left: 50px;
background-image:url(../icons/autoscroll.png);
background-repeat: no-repeat;
padding-bottom: 10px;
text-align: left;
font-weight: bold;
text-shadow: transparent 0 0 1px; /*anit-alias*/
}

#save_settings {
font-size:16px;
cursor:pointer;
width:160px;
margin:0 auto;
display:block;
}

#status_settings {
padding: 10px;
color: green;
}

#content {
margin: 10px 20px;
}

#version {
font-size:18px;
}

#donation {
padding: 5px 10px;
}
Binary file added icons/autoscroll.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
133 changes: 133 additions & 0 deletions js/background.js
@@ -0,0 +1,133 @@
/** @license
Simple Auto Scroll | MIT License
Copyright 2013 Jose Pablo Barrantes
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

function slowLabel(tab) {
chrome.browserAction.setBadgeBackgroundColor({color: [0,255,255,255]});
doScroll(tab, (localStorage["slow"] || "100"), 'slow');
};

function mediumLabel(tab) {
chrome.browserAction.setBadgeBackgroundColor({color: [0,255,0,255]});
doScroll(tab, (localStorage["medium"] || "40"), 'medium');
};

function fastLabel(tab) {
chrome.browserAction.setBadgeBackgroundColor({color: [0,21,183,32]});
doScroll(tab, (localStorage["fast"] || "1"), 'fast');
};

chrome.extension.getVersion = function() {
if (!chrome.extension.version_) {
var xhr = new XMLHttpRequest();
xhr.open("GET", chrome.extension.getURL('manifest.json'), false);
xhr.onreadystatechange = function() {
if (this.readyState == 4) {
var manifest = JSON.parse(this.responseText);
chrome.extension.version_ = manifest.version;
}
};
xhr.send();
}
return chrome.extension.version_;
};

document.addEventListener('DOMContentLoaded', function(e) {
var old_ver = (localStorage["version"] || "" ).split(".");
var new_ver = (chrome.extension.getVersion() + "").split(".");

if(old_ver[0]+'.'+old_ver[1]+'.'+old_ver[2] != new_ver[0]+'.'+new_ver[1]+'.'+new_ver[2]){
chrome.tabs.getAllInWindow(undefined, function(tabs) {
for (var i = 0, tab; tab = tabs[i]; i++) {
var str = tab.url;
if (str.match('http://github.com/jpablobr/simple-auto-scroll')) {
chrome.tabs.update(tab.id, {selected: true});
return;
}
}
chrome.tabs.create({url:'http://github.com/jpablobr/simple-auto-scroll'});
});

localStorage["version"] = chrome.extension.getVersion();
chrome.browserAction.setBadgeText({text:"new!"});
chrome.browserAction.setBadgeBackgroundColor({color:[0,255,255, 255]});

}
}, false);

var counter = 0;
var wN2scRl;

function doStop(tab) {
chrome.browserAction.setBadgeText({text:""});
var upUrl = "javascript:var wN2scRl;Sa5gNA9k=new Function('clearTimeout(wN2scRl)');document.onkeydown=Sa5gNA9k;Sa5gNA9k();void(wN2scRl=setInterval('if(pageYOffset<document.height-innerHeight){window.scrollBy(0,0)}else{Sa5gNA9k()}',0))";
if(upUrl != tab.url) {
chrome.tabs.update(tab.id, {'url': upUrl});
}
}

function doScroll(tab, speed, badge) {
chrome.browserAction.setBadgeText({text:badge});
wN2scRl = setInterval(function(){
upurl(tab.id);
}, speed);
}

function upurl(id){
chrome.tabs.update(id, {'url': 'javascript:document.body.scrollTop+=1;'});
}

chrome.extension.onRequest.addListener(function(request, sender, sendResponse) {
if(counter != 0){
chrome.tabs.getSelected(null, function(tab){
clearInterval(wN2scRl);
doStop(tab);
});
counter = 0;
}
sendResponse();
});

chrome.browserAction.onClicked.addListener(function(tab) {
clearInterval(wN2scRl);

if(counter == 0) {
counter +=1;
slowLabel(tab);
} else if(counter == 1) {
counter +=1;
mediumLabel(tab);
} else if(counter == 2) {
counter +=1;
fastLabel(tab);
} else if(counter == 3) {
counter = 0;
doStop(tab);
}
});

chrome.tabs.onSelectionChanged.addListener(function(tabid, selectinfo) {
clearInterval(wN2scRl);
chrome.browserAction.setBadgeText({text:""});
counter=0;
});
49 changes: 49 additions & 0 deletions js/options.js
@@ -0,0 +1,49 @@
/** @license
Simple Auto Scroll | MIT License
Copyright 2013 Jose Pablo Barrantes
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

var background = chrome.extension.getBackgroundPage();
document.addEventListener('DOMContentLoaded', function(e) {
document.getElementById("version").innerHTML = background.chrome.extension.getVersion();
init();
document.getElementById("save_settings").addEventListener('click', save_settings);
}, false);

function viewStatus(id, msg){
var status = document.getElementById(id);
status.innerHTML = msg;
setTimeout(function() { status.innerHTML = ""; }, 1 * 1000);
}

function init(){
document.getElementById("slow").value = (localStorage["slow"] || "80");
document.getElementById("medium").value = (localStorage["medium"] || "30");
document.getElementById("fast").value = (localStorage["fast"] || "1");
}

function save_settings() {
localStorage["slow"] = document.getElementById("slow").value + "";
localStorage["medium"] = document.getElementById("medium").value + "";
localStorage["fast"] = document.getElementById("fast").value + "";
viewStatus("status_settings","Options Saved.");
}
33 changes: 33 additions & 0 deletions js/simple_autoscroll.js
@@ -0,0 +1,33 @@
/** @license
Simple Auto Scroll | MIT License
Copyright 2013 Jose Pablo Barrantes
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

window.addEventListener('click', function(e){
chrome.extension.sendRequest({speed:'1'}, function(res){
});
}, false);

window.addEventListener('keydown', function(e){
chrome.extension.sendRequest({speed:'1'}, function(res){
});
}, false);

0 comments on commit 39761db

Please sign in to comment.