fixerinoed?

This commit is contained in:
qt31415926
2015-04-02 18:46:56 -04:00
5 changed files with 73 additions and 15 deletions
+7 -1
View File
@@ -26,5 +26,11 @@ The goal is to aid the rewiring of wanting long-term goals (short-term happiness
Monitoring my process. Started at HackWestern. <br>
v0.1 29/03/2015
- Knowledge basis: code academy javascript, stack overflow, github files of other chrome extensions, chrome extension api and docs.
- Heavily inspired by other anti distraction extensions, e.g. StayFocusd or ColdTurkey. Meant to be an alternative long term method to ween one self from short term reward systems.
- Heavily inspired by other anti distraction extensions, e.g. StayFocusd or ColdTurkey.
- Wanted to manipulate myself into not being distracted, by criticizing and causing cognitive dissonance.
- Knowledge gained: Negative, or annoyingly long to type guilt messages are draining. Hard to be productive when you're feeling shitty. Going to try to use inspiring, or user-empowering quotes that also make you think, but aren't depressing amongst other additional features in next vers.
v0.1.0.3 30/03/2015
- Changed UI so the alternatives are upfront, more immediate and relatively bigger. Intuitively that should be the focus, not the typing to unlock/go to the website.
- Learned a bit more jquery syntax. It's much nicer for manipulating html elements =D.
- The more positive focused thoughts seem better for now... Blind optimism doesn't seem appropriate here though.
+2
View File
@@ -8,7 +8,9 @@ blockService.set(DefaultList);
blockList = blockService.get();
blockChecker = new BlockCheck(DefaultList);
var currTabs = []; //TODO bugfix
var prevSite = "";
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
// console.log("Is this evenf ucking working details.url: " + details.url);
+30 -5
View File
@@ -30,19 +30,44 @@ var regexMatching = function(list, target){
return x.test(target);
}
function TabObject (tabId, origUrl, blockedStatus){
this.tabId = tabId;
this.currStatus = blockedStatus;
this.origUrl = origUrl;
this.changeStatus = function(newStatus){
this.currStatus = newStatus;
};
}
var BlockCheck = function(blocklist){
var storedUrl="";
var prevTabId;
// TODO include timestamps check var prevTimeStamp=0;
this.blocklist = blocklist;
this.redirectOnMatch = function(req){
var blocked = regexMatching(blocklist, req.url) && (req.tabId!==prevTabId) ;
if (blocked && req.method=="GET"){
console.log(req);
var tabBlock;
var blocked = regexMatching(blocklist, req.url)
var result = $.grep(currTabs, function(e){
return e.tabId == req.tabId;
});
if (result.length==0)
tabBlock= false;
else {
//validate if tab should be blocked again or not
//TODO ADD time functionality here
var resultStatus = result[0].currStatus;
if (resultStatus == false){
tabBlock = true;
}
}
blocked = blocked && !tabBlock;
if (blocked){
var toInsert = new TabObject(req.tabId, req.url, false);
currTabs.push(toInsert);
storedUrl = req.url;
if (req.tabId!==chrome.extension.getURL) prevTabId= req.tabId;
return {
redirectUrl : chrome.extension.getURL("background.html")
};
+32 -7
View File
@@ -44,14 +44,41 @@ window.onload = function setupUpdater(){
input.onkeydown=input.onkeyup=onClick=eventHandler;
};
var activate = function(){
var currTabs = chrome.extension.getBackgroundPage().currTabs;
chrome.tabs.query({
active: true,
windowId: window.id
}, function (tabs, req){
/* console.log("GPS CWGC tabs");
console.log(tabs);
console.log("GPS CWGC tabs[0]");
console.log(tabs[0]);
console.log("GPS CWGC currTabs");
console.log(currTabs);*/
result = $.grep(currTabs, function(e){
return e.tabId == tabs[0].id;
});
/* console.log("result");
console.log(result);*/
req = result;
if (req.length==0){
return "";
}
else{
$("#message").text("You've Unlocked The Button...\nI hope you don't regret this");
$(".btn-success").removeAttr("disabled");
$(".btn-success").attr("href", req[0].origUrl);
}
});
}
//Button Listener function yeah yeah its jquery and the rest of this wasnt, I am learning!
$(function(){
$(".btn-primary").click(function(){
if (passed){
$("#message").text("You've Unlocked The Button...\nI hope you don't regret this");
$(".btn-success").removeAttr("disabled");
console.log(chrome.extension.getBackgroundPage());
$(".btn-success").attr("href", chrome.extension.getBackgroundPage().prevSite);
activate();
}
else
$("#message").text("You failed! (typos are allowed)");
@@ -63,9 +90,7 @@ $(function(){
$('#input-a').keydown(function(e) {
if (e.keyCode == 13){
if (passed){
$("#message").text("You've Unlocked The Button...\nI hope you don't regret this");
$(".btn-success").removeAttr("disabled");
$(".btn-success").attr("href", chrome.extension.getBackgroundPage().prevSite);
activate();
}
else
$("#message").text("You failed! (typos are allowed)");
+2 -2
View File
@@ -2,9 +2,9 @@
"manifest_version": 2,
"name": "MAD - Mindful Anti Distraction",
"description": "This extension will hopefully help you be less distracted (untested)",
"version": "0.1.0.4",
"version": "0.1.0.5",
"background": {
"scripts": ["js/checkerino.js","background.js"],
"scripts": ["js/jquery.min.js","js/checkerino.js","background.js"],
"pages": ["background.html"]
},