mirror of
https://github.com/wassname/mad.git
synced 2026-07-17 01:30:40 +08:00
WOOHOOO IT WOOORRRRKKSSSSSSS
This commit is contained in:
+27
-8
@@ -25,19 +25,19 @@
|
||||
<div class="col-md-2"></div>
|
||||
</div>
|
||||
<div class="row text-center">
|
||||
<input id="submit1" class="btn btn-default" type="submit" value="Submit">
|
||||
<button id="submit2" type="button" class="btn btn-success">Test</button>
|
||||
<input id="submit1" class="btn btn-primary" type="submit" value="Submit">
|
||||
<a id="submit2" class="btn btn-success" href="#" disabled="enabled">Go Back</a>
|
||||
<br><strong></strong>
|
||||
</div>
|
||||
<div class="row">
|
||||
<h1 class="text-center">Change the Habit</h1>
|
||||
<br>
|
||||
<div id="alternate" class="row text-center">
|
||||
<div class="col-md-4">
|
||||
<a href="http://www.codecademy.com/learn">
|
||||
<img src="img/codeacad.jpg" class="img-circle">
|
||||
<div class="col-md-4 col-md-offset-2">
|
||||
<a href="https://keep.google.com/">
|
||||
<img src="img/gkeep.jpg" class="img-rounded">
|
||||
</a>
|
||||
<h3>Code in a new language</h3>
|
||||
<h3>Make/Look at your to-do list</h3>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<a href="https://www.khanacademy.org/">
|
||||
@@ -45,11 +45,30 @@
|
||||
</a>
|
||||
<h3>Learn new mathematics and sciences</h3>
|
||||
</div>
|
||||
<div class="col-md-4"><a href="https://www.duolingo.com/">
|
||||
<img src="img/duolingo.jpg" class="img-circle ">
|
||||
</div>
|
||||
<div id="alternate2" class="row text-center">
|
||||
<div class="col-md-4 col-md-offset-2">
|
||||
<a href="https://www.duolingo.com/">
|
||||
<img src="img/duolingo.jpg" class="img-circle">
|
||||
</a>
|
||||
<h3>Speak a new language, forever</h3>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<a href="http://www.codecademy.com/">
|
||||
<img src="img/codeacad.jpg" class="img-circle">
|
||||
</a>
|
||||
<h3>Code in a new language, forever</h3>
|
||||
</div>
|
||||
<!--
|
||||
<br>
|
||||
<a href="https://www.youtube.com/watch?v=KfnUicHDNM8">
|
||||
<h3><span class="glyphicon glyphicon-facetime-video" aria-hidden="true"></span> Roy Baumeister</h3>
|
||||
</a>
|
||||
<a href="https://www.youtube.com/watch?v=HTfYv3IEOqM">
|
||||
<h3><span class="glyphicon glyphicon-facetime-video" aria-hidden="true"></span> Daniel Golemann</h3>
|
||||
</a>
|
||||
-->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
+17
-3
@@ -1,8 +1,22 @@
|
||||
var blockChecker,
|
||||
blockList,
|
||||
blockService;
|
||||
|
||||
blockService = BlockListFactory.getBlockList();
|
||||
blockService.set(DefaultList);
|
||||
blockList = blockService.get();
|
||||
console.log(blockList);
|
||||
|
||||
console.log("did background.js load properly");
|
||||
blockChecker = new BlockCheck(DefaultList);
|
||||
|
||||
var prevSite = "";
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function(details) {
|
||||
console.log("Is this evenf ucking working details.url: " + details.url);
|
||||
console.log(details);
|
||||
return {redirectUrl: "http://google.com"};
|
||||
// console.log("Is this evenf ucking working details.url: " + details.url);
|
||||
// console.log(details);
|
||||
prevSite = blockChecker.getUrl();
|
||||
return blockChecker.redirectOnMatch(details);
|
||||
},
|
||||
{
|
||||
urls: ["<all_urls>"]
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 89 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 79 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+69
-5
@@ -1,5 +1,69 @@
|
||||
chrome.browserAction.onClicked.addListener(function(tab) {
|
||||
chrome.tabs.executeScript({
|
||||
code: 'document.body.style.backgroundColor="red"'
|
||||
});
|
||||
});
|
||||
|
||||
var DefaultList = [
|
||||
"facebook",
|
||||
"youtube",
|
||||
"twitter",
|
||||
"tumblr",
|
||||
"pinterest",
|
||||
"myspace",
|
||||
"livejournal",
|
||||
"digg",
|
||||
"stumbleupon",
|
||||
"reddit",
|
||||
"kongregate",
|
||||
"newgrounds",
|
||||
"addictinggames",
|
||||
"hulu",
|
||||
"pornhub"
|
||||
];
|
||||
var regexMatching = function(list, target){
|
||||
var start = '^(http|https)://(www\\.)?(';
|
||||
var end = '\\.(be|com|org|net)/[\\W\\w]*$';
|
||||
var middle = "";
|
||||
for (var i = 0; i < list.length-1; i++){
|
||||
middle = middle+list[i]+'|';
|
||||
}
|
||||
middle = middle+list[list.length-1]+')';
|
||||
var x = new RegExp(start+middle+end);
|
||||
//console.log("what is target: " + target);
|
||||
//console.log("what is xtesttarget: " + x.test(target));
|
||||
return x.test(target);
|
||||
}
|
||||
|
||||
|
||||
var BlockCheck = function(blocklist){
|
||||
var storedUrl="";
|
||||
var prevTabId;
|
||||
// TODO include timestamps check var prevTimeStamp=0;
|
||||
this.blocklist = blocklist;
|
||||
|
||||
this.redirectOnMatch = function(req){
|
||||
console.log(req);
|
||||
var blocked = regexMatching(blocklist, req.url) && (req.tabId!==prevTabId) ;
|
||||
if (blocked){
|
||||
storedUrl = req.url;
|
||||
prevTabId= req.tabId;
|
||||
return {
|
||||
redirectUrl : chrome.extension.getURL("background.html")
|
||||
};
|
||||
}
|
||||
};
|
||||
this.getUrl = function(){
|
||||
return storedUrl;
|
||||
};
|
||||
};
|
||||
|
||||
var BlockList = function (){
|
||||
this.get = function(){
|
||||
return JSON.parse(localStorage['blocklist']);
|
||||
};
|
||||
this.set = function(data){
|
||||
localStorage['blocklist'] = JSON.stringify(data);
|
||||
};
|
||||
};
|
||||
|
||||
var BlockListFactory = {
|
||||
getBlockList: function(){
|
||||
return new BlockList();
|
||||
}
|
||||
};
|
||||
|
||||
+13
-17
@@ -1,9 +1,3 @@
|
||||
/* A convenience function to reverse a string, and
|
||||
* one to set the content of an element.
|
||||
*/
|
||||
|
||||
function reverse(s){return s.split('').reverse().join('')}
|
||||
|
||||
function set(el,text){
|
||||
while(el.firstChild)el.removeChild(el.firstChild);
|
||||
el.appendChild(document.createTextNode(text))
|
||||
@@ -11,10 +5,11 @@ function set(el,text){
|
||||
|
||||
var sayings = [
|
||||
"I am in control over what I am doing. I am not distracted",
|
||||
"I am as aware of my tongue as much as I am aware of how distracted the site I am going to can make me",
|
||||
"I have done all my goals today and am focused",
|
||||
"I can totally type to 10 and still choose not to go to an alternative site. 1 2 3 4 5 6 7 8 9 10.",
|
||||
"I am not habitually going to this site after creating a new tab. I have good reasons for going to this site",
|
||||
"I can always go to this site later in the day and there is no urgency to visit this site, but I am going anyways"
|
||||
"There are so many better things to do. I'll still go through typing this to experience this banal web site.",
|
||||
"I can always go to this site later in the day and there is no urgency to visit this site, but I am going anyways despite what's best for me"
|
||||
]
|
||||
/* setupUpdater will be called once, on page load.
|
||||
*/
|
||||
@@ -29,8 +24,10 @@ window.onload = function setupUpdater(){
|
||||
, oldText=input
|
||||
, timeout=null;
|
||||
|
||||
set(target, targetText);
|
||||
/* handleChange is called 50ms after the user stops
|
||||
set(target, targetText);
|
||||
|
||||
|
||||
/* handleChange is called 200ms after the user stops
|
||||
typing. */
|
||||
function handleChange(){
|
||||
var newText=input.value;
|
||||
@@ -44,24 +41,23 @@ window.onload = function setupUpdater(){
|
||||
set(orig, 'Debug: Score:' + score);
|
||||
}
|
||||
|
||||
/* eventHandler is called on keyboard and mouse events.
|
||||
If there is a pending timeout, it cancels it.
|
||||
It sets a timeout to call handleChange in 50ms. */
|
||||
function eventHandler(){
|
||||
if(timeout) clearTimeout(timeout);
|
||||
timeout=setTimeout(handleChange, 200);
|
||||
timeout=setTimeout(handleChange, 130);
|
||||
}
|
||||
input.onkeydown=input.onkeyup=onClick=eventHandler;
|
||||
};
|
||||
|
||||
//Button Listener function
|
||||
$(function(){
|
||||
$(".btn").click(function(){
|
||||
$(".btn-primary").click(function(){
|
||||
if (passed){
|
||||
$("strong").text("Debug: YOU PASSED");
|
||||
$(".btn-success").removeAttr("disabled");
|
||||
console.log(chrome.extension.getBackgroundPage());
|
||||
$(".btn-success").attr("href", chrome.extension.getBackgroundPage().prevSite);
|
||||
}
|
||||
else
|
||||
$("strong").text("Debug: YOU FAILED");
|
||||
$("strong").text("You failed! (typos are allowed)");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@
|
||||
"description": "This addon will help you be less distracted",
|
||||
"version": "1.0",
|
||||
"background": {
|
||||
"scripts": ["background.js"],
|
||||
"scripts": ["js/checkerino.js","background.js"],
|
||||
"pages": ["background.html"]
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user