using grunt, added reason tracker prototype
@@ -1,2 +1,7 @@
|
||||
*.swp
|
||||
*.swo
|
||||
dist
|
||||
node_modules
|
||||
tmp
|
||||
*.pem
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
module.exports = function( grunt ) {
|
||||
'use strict';
|
||||
|
||||
grunt.loadNpmTasks('grunt-crx');
|
||||
grunt.loadNpmTasks('grunt-contrib-compress');
|
||||
|
||||
var config = {
|
||||
app: 'src',
|
||||
dist: 'dist',
|
||||
package: grunt.file.readJSON('package.json')
|
||||
};
|
||||
|
||||
grunt.initConfig({
|
||||
config: config,
|
||||
crx: {
|
||||
testPackage: {
|
||||
"src": "<%= config.app %>",
|
||||
"dest": "<%= config.dist %>/crx/",
|
||||
"zipDest": "<%= config.dist %>/<%= config.package.name %>-<%= config.package.version %>.zip",
|
||||
"privateKey": "<%= config.dist %>/mad.pem"
|
||||
},
|
||||
},
|
||||
compress: {
|
||||
dist:{
|
||||
options: {
|
||||
archive: '<%= config.dist %>/<%= config.package.name %>-<%= config.package.version %>.zip'
|
||||
},
|
||||
files: [{
|
||||
expand: true,
|
||||
cwd: '<%= config.app %>/',
|
||||
src: ['**'],
|
||||
dest: ''
|
||||
}]
|
||||
}
|
||||
}
|
||||
});
|
||||
grunt.registerTask('updatejson', function (key, value) {
|
||||
var projectFile = "src/manifest.json";
|
||||
|
||||
if (!grunt.file.exists(projectFile)) {
|
||||
grunt.log.error("file " + projectFile + " not found");
|
||||
return true;//return false to abort the execution
|
||||
}
|
||||
var project = grunt.file.readJSON(projectFile);//get file as json object
|
||||
|
||||
project['version']= config.package.version;//edit the value of json object, you can also use projec.key if you know what you are updating
|
||||
|
||||
grunt.file.write(projectFile, JSON.stringify(project, null, 2));//serialize it back to file
|
||||
|
||||
});
|
||||
grunt.registerTask('default', ['crx', 'compress', 'updatejson']
|
||||
);
|
||||
|
||||
};
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
var currTabs = []; //TODO add additional information to these objects, e.g. time
|
||||
var prevSite = "";
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function(details) {
|
||||
// console.log("Is this evenf ucking working details.url: " + details.url);
|
||||
prevSite = blockChecker.getUrl();
|
||||
return blockChecker.redirectOnMatch(details);
|
||||
},
|
||||
{
|
||||
urls: ["<all_urls>"]
|
||||
},
|
||||
["blocking"]
|
||||
);
|
||||
@@ -1,64 +0,0 @@
|
||||
|
||||
app.controller('AltController', ['$scope', '$modal',
|
||||
function($scope){
|
||||
$scope.bools = {};
|
||||
$scope.bools.addingItem = false;
|
||||
|
||||
chrome.storage.sync.get('alternatives', function(items){
|
||||
if (items.alternatives == undefined ){
|
||||
$scope.alternatives = defaultAlternatives;
|
||||
} else{
|
||||
$scope.alternatives = items.alternatives;
|
||||
}
|
||||
/*console.log(items);
|
||||
console.log(items.length);
|
||||
console.log($scope.alternatives);*/
|
||||
$scope.$apply();
|
||||
});
|
||||
|
||||
$scope.deleteAlt = function(index){
|
||||
if (confirm('Are you sure you want to delete?')== true){
|
||||
$scope.alternatives.splice(index,1);
|
||||
chrome.storage.sync.set({'alternatives': $scope.alternatives}, function(){
|
||||
console.log('alternatives saved');
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
$scope.switchAdd = function(){
|
||||
//console.log("tis workings? " + $scope.bools.addingItem);
|
||||
$scope.bools.addingItem = !$scope.bools.addingItem;
|
||||
};
|
||||
|
||||
function newAltObject(text, href, imgsrc)
|
||||
{
|
||||
this.text = text;
|
||||
this.href = href;
|
||||
this.imgsrc = imgsrc;
|
||||
};
|
||||
|
||||
|
||||
$scope.submitNew = function(){
|
||||
/* console.log("does this function activate");
|
||||
console.log("new alt text: " + $scope.newAltText +" new altUrl: " + $scope.newAltUrl);*/
|
||||
randInt = Math.floor((Math.random()*5));
|
||||
$scope.newAltImgSrc = 'img/default/happy' + randInt + '.png';
|
||||
var altLink = {
|
||||
text: $scope.newAltText,
|
||||
href: $scope.newAltUrl,
|
||||
imgsrc: $scope.newAltImgSrc
|
||||
};
|
||||
$scope.alternatives.push(altLink);
|
||||
$scope.newAltUrl= "";
|
||||
$scope.newAltText = "";
|
||||
$scope.switchAdd();
|
||||
chrome.storage.sync.set({'alternatives': $scope.alternatives}, function(){
|
||||
console.log('alternatives saved');
|
||||
});
|
||||
/*console.log('loggin in submit');
|
||||
console.log($scope.alternatives);*/
|
||||
};
|
||||
|
||||
|
||||
}]);
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "MAD - Mindful Anti Distraction",
|
||||
"short_name": "MAD BETA",
|
||||
"description": "This extension will hopefully help you be less distracted",
|
||||
"version": "0.2.1.1",
|
||||
"background": {
|
||||
"scripts": ["js/shared/jquery.min.js","js/checkerino.js","background.js"],
|
||||
"pages": ["background.html"]
|
||||
},
|
||||
|
||||
"browser_action": {
|
||||
"default_icon": "img/128.png",
|
||||
"default_title": "MAD",
|
||||
"default_popup": "popup.html"
|
||||
},
|
||||
|
||||
"web_accessible_resources":[
|
||||
"background.html",
|
||||
"css/*",
|
||||
"js/*"
|
||||
],
|
||||
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
|
||||
|
||||
"permissions": [
|
||||
"activeTab",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"storage",
|
||||
"<all_urls>",
|
||||
"tabs"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "Mindful-Anti-Distraction",
|
||||
"version": "0.3.0",
|
||||
"description": "Chrome extension to help curtail poor internet habits",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/qt31415926/mad"
|
||||
},
|
||||
"private": true,
|
||||
"devDependencies": {
|
||||
"grunt": "^0.4.5",
|
||||
"grunt-contrib-compress": "^0.13.0",
|
||||
"grunt-crx": "^0.3.4",
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,14 @@
|
||||
<!--Controllers -->
|
||||
<script src="js/controllers/altController.js"></script>
|
||||
<script src="js/controllers/headerController.js"></script>
|
||||
<script src="js/controllers/footerController.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="text-center content" ng-controller="HeaderController">
|
||||
<h1>MAD: <small>Mindful Anti Distraction</small></h1>
|
||||
<button class='btn btn-danger' ng-click='openOptions("lg")'>Block List</button>
|
||||
<button class='btn btn-success' ng-click='openReasons("lg")'>Reason Tracker</button>
|
||||
</div>
|
||||
|
||||
<div class="row content">
|
||||
@@ -36,16 +38,26 @@
|
||||
<br>
|
||||
<div id="alternate" class="row text-center" ng-controller="AltController">
|
||||
<div ng-repeat="alt in alternatives track by $index" class="col-md-3 col-sm-3 col-xs-3">
|
||||
<div ng-hide="editMode[$index]">
|
||||
<a ng-href="{{ alt.href || urlFilter }}" style="text-decoration: none">
|
||||
<img ng-src="{{ alt.imgsrc }}" class="img-circle">
|
||||
<img ng-src="{{ alt.imgsrc }}" class="restrict-img-circle img-circle">
|
||||
<h3>{{ alt.text }}</h3>
|
||||
</a>
|
||||
<button class='btn btn-xs btn-danger' ng-click='deleteAlt($index)'>X</button>
|
||||
</div>
|
||||
<div ng-hide="!editMode[$index]">
|
||||
<a href=""><span class='glyphicon glyphicon-chevron-left' aria-hidden="true" ng-click='switchPic("left", $index)'></span></a>
|
||||
<img ng-src="{{ alt.imgsrc }}" class="restrict-img-circle img-circle">
|
||||
<a href=""><span class='glyphicon glyphicon-chevron-right' aria-hidden="true" ng-click='switchPic("right", $index)'></span></a>
|
||||
<input class='form-control text-center nice-form-control' ng-model="alt.text" ></h3>
|
||||
</div>
|
||||
<button class='btn btn-xs btn-danger' ng-click='deleteAlt($index)'><span class='glyphicon glyphicon-trash' aria-hidden="true"></span></button>
|
||||
<button class='btn btn-xs btn-warning' ng-click='editAlt($index)'><span class='glyphicon glyphicon-wrench' aria-hidden="true"></span></button>
|
||||
</div>
|
||||
|
||||
|
||||
<div id="previewAlt" class="col-md-3 col-sm-3 col-xs-3" ng-hide="!bools.addingItem">
|
||||
<img ng-src="img/default/happygrey.png"class="img-circle" height="140" width="140">
|
||||
<img ng-show="!NIform.imgurl.$invalid" ng-src="img/default/happygrey.png"class="restrict-img-circle img-circle" height="140" width="140">
|
||||
<img ng-show="NIform.imgurl.$invalid" ng-src="{{newAltImgUrl}}" class="restrict-img-circle img-circle">
|
||||
<h3> {{ newAltText }} </h3>
|
||||
<p> PREVIEW </p>
|
||||
</div>
|
||||
@@ -74,8 +86,10 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class='form-group'>
|
||||
<label for='inputImg' class='col-sm-offset-2 col-sm-2 control-label'>Upload Image (COMING SOON!)</label>
|
||||
<input type="file" disabled='disabled' class="col-sm-4 btn btn-primary" id='submitPhoto' nv-file-select uploader='upload' value="Upload"/>
|
||||
<label for='inputUrl' class='col-sm-offset-2 col-sm-2 control-label'>Image Link (Optional)</label>
|
||||
<div class='col-sm-4'>
|
||||
<input id='inputUrl' type='url' name='imgurl' class='form-control' ng-model='newAltImgUrl' ng-minlength='1'>
|
||||
</div>
|
||||
</div>
|
||||
<input type="submit" ng-disabled='NIform.$invalid' class='btn btn-primary' id='submit' value='Submit'/>
|
||||
<button type="button" class="btn btn-danger" ng-click="switchAdd()"> Cancel </button>
|
||||
@@ -100,8 +114,9 @@
|
||||
</a>
|
||||
-->
|
||||
|
||||
<div class="row content-a">
|
||||
<div class="col-md-8 col-md-offset-2 text-center">
|
||||
<div class="row content-a" ng-controller="FooterController">
|
||||
<div class="row text-center">
|
||||
<div class="col-md-8 col-md-offset-2 ">
|
||||
<p>Read and <strong>type the text below</strong> if you <strong>REALLY HAVE</strong> to go to your site:</p>
|
||||
<div class="jumbotron-cust">
|
||||
<blockquote>
|
||||
@@ -110,19 +125,34 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<div class="container">
|
||||
<div class="content-a">
|
||||
<div class="form-inline">
|
||||
<form class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label for="input-a">Retype</label>
|
||||
<label class="col-sm-2 control-label" for="input-a">Retype</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" id="input-a" class="custwidth form-control"></input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label" for="input-b">Reason Tracking (Optional)</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" id="input-b" class="custwidth form-control" ng-model="reason"></input>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<input id="submit1" class="btn btn-primary" type="submit" value="Verify">
|
||||
<a id="submit2" class="btn btn-success" href="#" disabled="enabled">Enter Site</a>
|
||||
<a id="submit2" class="btn btn-success" href="#" disabled="enabled" ng-click='enterSite()'>Enter Site</a>
|
||||
<br><strong id="message"></strong>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
<h2 class="btn btn-danger text-center">HELP IM DISTRACTED</h2>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
var currTabs = []; //TODO add additional information to these objects, e.g. time
|
||||
var updateInterval = 5;
|
||||
var cumulativeTime = 0;
|
||||
var totalTime = 0;
|
||||
|
||||
function updateTimes(){
|
||||
chrome.idle.queryState(60, function (state){
|
||||
if (state === "active"){
|
||||
chrome.tabs.query({
|
||||
active: true,
|
||||
currentWindow: true
|
||||
}, function callback(tabs){
|
||||
var currentTab = tabs[0];
|
||||
var regexBlockCheck = (typeof currentTab == 'undefined') ? false : regexMatching(blockList, currentTab.url);
|
||||
if (regexBlockCheck) {
|
||||
totalTime +=5;
|
||||
cumulativeTime +=5;
|
||||
chrome.browserAction.setIcon({path: 'img/38unhappy.png'});
|
||||
} else {
|
||||
chrome.browserAction.setIcon({path: 'img/38.png'});
|
||||
}
|
||||
});
|
||||
} else{
|
||||
chrome.browserAction.setIcon({path: 'img/38.png'});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
chrome.webRequest.onBeforeRequest.addListener(
|
||||
function(details) {
|
||||
return blockChecker.redirectOnMatch(details);
|
||||
},
|
||||
{
|
||||
urls: ["<all_urls>"]
|
||||
},
|
||||
["blocking"]
|
||||
);
|
||||
|
||||
setInterval(updateTimes, updateInterval * 1000);
|
||||
@@ -34,7 +34,7 @@
|
||||
<div class='col-md-5'>
|
||||
<h3>ASSIST FUTURE SELF</h3>
|
||||
<div class='row'>
|
||||
<h4>Simple Domain Block</h4>
|
||||
<h4>Simple Block</h4>
|
||||
<div class='col-md-10'>
|
||||
<input id="simpleDomain" ng-model="simple" type='text' class='form-control' placeholder='e.g. reddit or twitter'/>
|
||||
</div>
|
||||
@@ -52,3 +52,17 @@ blockquote{
|
||||
.modal-right-button{
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
.nice-form-control{
|
||||
margin-top: 20px;
|
||||
margin-bottom: 10px;
|
||||
font-size: 24px;
|
||||
color: #337AB7;
|
||||
}
|
||||
|
||||
.restrict-img-circle{
|
||||
max-width: 150px;
|
||||
max-height: 150px;
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 106 KiB After Width: | Height: | Size: 106 KiB |
|
After Width: | Height: | Size: 15 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 452 B After Width: | Height: | Size: 452 B |
|
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
|
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
|
Before Width: | Height: | Size: 9.8 KiB After Width: | Height: | Size: 9.8 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 9.5 KiB After Width: | Height: | Size: 9.5 KiB |
|
Before Width: | Height: | Size: 8.3 KiB After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 12 KiB |
|
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
@@ -21,7 +21,8 @@ var regexMatching = function(list, target){
|
||||
];
|
||||
|
||||
var redirSites = [
|
||||
"facebook.com/l.php"
|
||||
"facebook.com/l.php",
|
||||
"youtube.com/redirect"
|
||||
];
|
||||
var simpleSiteRegex,
|
||||
generalRegex,
|
||||
@@ -35,7 +36,12 @@ var regexMatching = function(list, target){
|
||||
}
|
||||
domains = domains + ')'
|
||||
var end = '\\.'+ domains + '/[\\W\\w]*$';
|
||||
redirRegex = new RegExp(start + redirSites[0] + '.*$');
|
||||
|
||||
var redir = '(' + redirSites[0];
|
||||
for (var j=1; j< redirSites.length; j++){
|
||||
redir = redir + '|' + redirSites[j];
|
||||
}
|
||||
redirRegex = new RegExp(start + redir + ')' + '.*$');
|
||||
simpleSiteRegex = new RegExp(start+'.*$');
|
||||
var middle = "";
|
||||
var exactsiesBlock = false;
|
||||
@@ -0,0 +1,124 @@
|
||||
var defaultImgsSize = 6;
|
||||
|
||||
app.controller('AltController', ['$scope', '$modal',
|
||||
function($scope){
|
||||
$scope.bools = {};
|
||||
$scope.bools.addingItem = false;
|
||||
$scope.bools.addingImg = false;
|
||||
|
||||
chrome.storage.sync.get('alternatives', function(items){
|
||||
if (items.alternatives == undefined ){
|
||||
$scope.alternatives = defaultAlternatives;
|
||||
} else{
|
||||
$scope.alternatives = items.alternatives;
|
||||
}
|
||||
/*console.log(items);
|
||||
console.log(items.length);
|
||||
console.log($scope.alternatives);*/
|
||||
$scope.editMode = new Array($scope.alternatives.length);
|
||||
for (var i = 0 ; i < $scope.alternatives.length ; i++){
|
||||
$scope.editMode[i]=false;
|
||||
}
|
||||
updateListOfPics();
|
||||
$scope.$apply();
|
||||
});
|
||||
|
||||
$scope.deleteAlt = function(index){
|
||||
if (confirm('Are you sure you want to delete?')== true){
|
||||
$scope.alternatives.splice(index,1);
|
||||
chrome.storage.sync.set({'alternatives': $scope.alternatives}, function(){
|
||||
console.log('alternatives saved');
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
$scope.switchAdd = function(){
|
||||
console.log("tis workings? " + $scope.bools.addingItem);
|
||||
if($scope.bools.addingItem == false){
|
||||
$scope.newAltText = "";
|
||||
$scope.newAltUrl = "";
|
||||
$scope.newAltImgUrl = "";
|
||||
}
|
||||
$scope.bools.addingItem = !$scope.bools.addingItem;
|
||||
};
|
||||
|
||||
function newAltObject(text, href, imgsrc)
|
||||
{
|
||||
this.text = text;
|
||||
this.href = href;
|
||||
this.imgsrc = imgsrc;
|
||||
};
|
||||
|
||||
|
||||
$scope.submitNew = function(){
|
||||
randInt = Math.floor((Math.random()*defaultImgsSize));
|
||||
var def = ($scope.newAltImgUrl == "") ? 'img/default/happy' + randInt + '.png' : $scope.newAltImgUrl;
|
||||
console.log("imgsrc is: " + def + " scope new alt img url: " + $scope.newAltImgUrl);
|
||||
|
||||
var altLink = {
|
||||
text: $scope.newAltText,
|
||||
href: $scope.newAltUrl,
|
||||
imgsrc: def
|
||||
};
|
||||
$scope.alternatives.push(altLink);
|
||||
$scope.newAltUrl= "";
|
||||
$scope.newAltText = "";
|
||||
$scope.switchAdd();
|
||||
chrome.storage.sync.set({'alternatives': $scope.alternatives}, function(){
|
||||
console.log('alternatives saved');
|
||||
});
|
||||
/*console.log('loggin in submit');
|
||||
console.log($scope.alternatives);*/
|
||||
};
|
||||
|
||||
$scope.$watch('alternatives', function(newVal){
|
||||
chrome.storage.sync.set({'alternatives': $scope.alternatives}, function(){
|
||||
});
|
||||
},true);
|
||||
|
||||
$scope.editAlt = function(index){
|
||||
$scope.editMode[index] = !$scope.editMode[index];
|
||||
};
|
||||
|
||||
|
||||
$scope.listUrls = [];
|
||||
|
||||
var updateListOfPics = function(){
|
||||
for (var i = 0; i < $scope.alternatives.length; i++){
|
||||
var bool = false;
|
||||
|
||||
$scope.listUrls.push($scope.alternatives[i].imgsrc);
|
||||
}
|
||||
for (var i = 0; i < defaultImgsSize; i++){
|
||||
var defaultPicUrl = 'img/default/happy' + i + '.png';
|
||||
if (!(defaultPicUrl in $scope.listUrls)){
|
||||
$scope.listUrls.push(defaultPicUrl);
|
||||
}
|
||||
}
|
||||
var out = [];
|
||||
var seen = {};
|
||||
var len = $scope.listUrls.length;
|
||||
var j = 0;
|
||||
for(var i = 0; i < len; i++) {
|
||||
var item = $scope.listUrls[i];
|
||||
if(seen[item] !== 1) {
|
||||
seen[item] = 1;
|
||||
out[j++] = item;
|
||||
}
|
||||
}
|
||||
$scope.listUrls = out;
|
||||
}
|
||||
|
||||
$scope.switchPic = function(dir, index){
|
||||
var curIndexInArray = $scope.listUrls.indexOf($scope.alternatives[index].imgsrc);
|
||||
if (dir=='left'){
|
||||
$scope.alternatives[index].imgsrc = $scope.listUrls[((curIndexInArray+$scope.listUrls.length)-1)%$scope.listUrls.length];
|
||||
} else if (dir=='right'){
|
||||
$scope.alternatives[index].imgsrc = $scope.listUrls[((curIndexInArray+$scope.listUrls.length)+1)%$scope.listUrls.length];
|
||||
}
|
||||
chrome.storage.sync.set({'alternatives': $scope.alternatives}, function(){
|
||||
});
|
||||
};
|
||||
|
||||
}]);
|
||||
@@ -0,0 +1,22 @@
|
||||
app.controller('FooterController', ['$scope', '$modal',
|
||||
function($scope){
|
||||
chrome.storage.sync.get('reasons', function(items){
|
||||
if (items.reasons == undefined){
|
||||
$scope.listOfReasons = [];
|
||||
} else {
|
||||
$scope.listOfReasons = items.reasons;
|
||||
}
|
||||
$scope.$apply();
|
||||
});
|
||||
|
||||
$scope.enterSite = function(){
|
||||
if ($scope.reason == "") return;
|
||||
console.log($scope.listOfReasons);
|
||||
$scope.listOfReasons.push($scope.reason);
|
||||
chrome.storage.sync.set( {'reasons': $scope.listOfReasons}, function(){
|
||||
});
|
||||
console.log($scope.listOfReasons);
|
||||
};
|
||||
|
||||
|
||||
}]);
|
||||
@@ -1,13 +1,23 @@
|
||||
var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
var ReasonTrackerModalInstanceCtrl = function($scope, $modalInstance){
|
||||
$scope.cancel = function() {
|
||||
$modalInstance.dismiss('cancel');
|
||||
};
|
||||
|
||||
chrome.storage.sync.get('reasons', function(item){
|
||||
if (item.reasons == undefined){
|
||||
$scope.reasons = [];
|
||||
} else {
|
||||
console.log(item.reasons);
|
||||
$scope.reasons = item.reasons;
|
||||
}
|
||||
$scope.$apply();
|
||||
});
|
||||
};
|
||||
var BlockListModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
|
||||
$scope.blocklist = bkg.blockList;
|
||||
//$scope.enabledEdits = [];
|
||||
//keep track of every action
|
||||
//for each action keep type and what was done
|
||||
//redo in queue like fashion?
|
||||
$scope.undoBool = true;
|
||||
chrome.storage.sync.set({'alternatives': $scope.alternatives}, function(){
|
||||
console.log('saved');
|
||||
});
|
||||
$scope.undoHistoryQueue = [];
|
||||
|
||||
@@ -38,15 +48,13 @@ var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
|
||||
$scope.deleteBlock = function(index) {
|
||||
if (!$scope.firstTimeDelete){
|
||||
if (confirm('Hey! You can still go to this site. You just gotta type a tiny message. (psst press cancel)')){
|
||||
if (confirm("You can delete from now on if you press OK. But I can't even think of a scenario in which deleting will help in the long run")){
|
||||
if (confirm("You can delete from now on if you press OK. But it may be better to leave things as they are.")){
|
||||
$scope.firstTimeDelete = true;
|
||||
chrome.storage.sync.set({'firstTimeDelete': $scope.firstTimeDelete}, function(){
|
||||
console.log('firstTimeDelete saved');
|
||||
});
|
||||
$scope.deleteBlock(index);
|
||||
}
|
||||
}
|
||||
} else{
|
||||
$scope.undoHistoryQueue.push({
|
||||
type: 'deletion',
|
||||
@@ -101,15 +109,23 @@ var ModalInstanceCtrl = function($scope, $modalInstance) {
|
||||
|
||||
app.controller('HeaderController', ['$scope', '$modal',
|
||||
function($scope, $modal){
|
||||
console.log('header controller');
|
||||
$scope.openOptions = function(size) {
|
||||
var modalInstance = $modal.open({
|
||||
templateUrl:'../../options.html',
|
||||
controller: ModalInstanceCtrl,
|
||||
templateUrl:'../../blocklist.html',
|
||||
controller: BlockListModalInstanceCtrl,
|
||||
size: size
|
||||
});
|
||||
};
|
||||
|
||||
$scope.openReasons = function(size){
|
||||
var modalInstance = $modal.open({
|
||||
templateUrl:'../../reasons.html',
|
||||
controller: ReasonTrackerModalInstanceCtrl,
|
||||
size: size
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}]);
|
||||
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
//implement focus to quit directive
|
||||
app.directive('focus', function($document,$window){
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: null,
|
||||
replace:
|
||||
}
|
||||
});
|
||||
@@ -1,16 +1,21 @@
|
||||
function set(el,text){
|
||||
while(el.firstChild)el.removeChild(el.firstChild);
|
||||
while (el.firstChild) {
|
||||
el.removeChild(el.firstChild);
|
||||
}
|
||||
el.appendChild(document.createTextNode(text))
|
||||
}
|
||||
|
||||
var defSayings = [
|
||||
"I am in control over my actions",
|
||||
"I have done my main goals for the day and need to use this website",
|
||||
"Sites are simply tools. They don't control me",
|
||||
"I am aware of my main goals for the day",
|
||||
"Sites are only tools. They don't control me",
|
||||
"Resisting this site is easy",
|
||||
"I ain't gonna get tricky tricked by my mindless monotony",
|
||||
"I am going here not out of habit, but for a solid purpose",
|
||||
"Taking a second and thinkin a linkin"
|
||||
"Not all those who wander are lost",
|
||||
"I will fight my automatic actions",
|
||||
"Conserve willpower through smart choices",
|
||||
"Mindless rote behaviour is changeable",
|
||||
"Refocus on what needs to be done",
|
||||
"What was the cue that led me here?"
|
||||
]
|
||||
/* setupUpdater will be called once, on page load.
|
||||
*/
|
||||
@@ -28,7 +33,6 @@ window.onload = function setupUpdater(){
|
||||
function handleChange(){
|
||||
var newText=input.value;
|
||||
var score = a.get(newText)[0][0];
|
||||
// console.log("handling change: score: " + score);
|
||||
if (score>0.88) {
|
||||
passed = true;
|
||||
return;
|
||||
@@ -37,58 +41,59 @@ window.onload = function setupUpdater(){
|
||||
}
|
||||
|
||||
function eventHandler(){
|
||||
if(timeout) clearTimeout(timeout);
|
||||
timeout=setTimeout(handleChange, 50);
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
timeout=setTimeout(handleChange, 30);
|
||||
}
|
||||
input.onkeydown=input.onkeyup=onClick=eventHandler;
|
||||
};
|
||||
|
||||
var activate = function(){
|
||||
// console.log("does activate function trigger");
|
||||
var currTabs = chrome.extension.getBackgroundPage().currTabs;
|
||||
chrome.tabs.query({
|
||||
active: true,
|
||||
windowId: chrome.windows.WINDOW_ID_CURRENT
|
||||
}, function (tabs){
|
||||
result = $.grep(currTabs, function(e){
|
||||
console.log(currTabs);
|
||||
e.currStatus = false;
|
||||
return e.tabId == tabs[0].id;
|
||||
});
|
||||
console.log(result[0]);
|
||||
if (result.length==0){
|
||||
return "";
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
$("#message").text("You've Unlocked The Button...\nI hope you don't regret this");
|
||||
$("#message").text("Button Unlocked");
|
||||
console.log(result[0]);
|
||||
$(".btn-success").removeAttr("disabled");
|
||||
$(".btn-success").attr("href", result[0].origUrl);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
return 'poop';
|
||||
return false;
|
||||
}
|
||||
|
||||
//Button Listener function yeah yeah its jquery and the rest of this wasnt, I am learning!
|
||||
//jquery (old code)
|
||||
//click listener
|
||||
$(function(){
|
||||
$(".btn-primary").click(function(){
|
||||
if (passed) {
|
||||
activate();
|
||||
} else {
|
||||
$("#message").text("Some typos are allowed, but not that many!");
|
||||
}
|
||||
else
|
||||
$("#message").text("You failed! (some typos are allowed)");
|
||||
});
|
||||
});
|
||||
|
||||
//enter listener
|
||||
$(function(){
|
||||
$('#input-a').keydown(function(e) {
|
||||
$('#input-a, #input-b').keydown(function(e) {
|
||||
if (e.keyCode == 13){
|
||||
if (passed) {
|
||||
activate();
|
||||
} else {
|
||||
$("#message").text("Some typos are allowed, but not that many!");
|
||||
}
|
||||
else
|
||||
$("#message").text("You failed! (some typos are allowed)");
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "MAD - Mindful Anti Distraction",
|
||||
"short_name": "MAD BETA",
|
||||
"description": "This extension will hopefully help you be less distracted",
|
||||
"version": "0.3.0",
|
||||
"background": {
|
||||
"scripts": [
|
||||
"js/shared/jquery.min.js",
|
||||
"js/checkerino.js",
|
||||
"background.js"
|
||||
],
|
||||
"pages": [
|
||||
"background.html"
|
||||
]
|
||||
},
|
||||
"browser_action": {
|
||||
"default_icon": "img/128.png",
|
||||
"default_title": "MAD",
|
||||
"default_popup": "popup.html"
|
||||
},
|
||||
"web_accessible_resources": [
|
||||
"background.html",
|
||||
"css/*",
|
||||
"js/*"
|
||||
],
|
||||
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
|
||||
"permissions": [
|
||||
"activeTab",
|
||||
"webRequest",
|
||||
"webRequestBlocking",
|
||||
"storage",
|
||||
"idle",
|
||||
"<all_urls>",
|
||||
"tabs"
|
||||
]
|
||||
}
|
||||
@@ -5,6 +5,7 @@
|
||||
<script src="js/shared/angular.min.js"></script>
|
||||
<script src="js/popup.js"></script>
|
||||
<script src="js/shared/bootstrap.min.js"></script>
|
||||
<script src="js/shared/angular-strap.min.js"></script>
|
||||
|
||||
<!-- Stylin Style Sheets-->
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
@@ -16,11 +17,13 @@
|
||||
<script src="js/controllers/popupController.js"></script>
|
||||
</head>
|
||||
|
||||
<body style="width:135px" ng-controller="PopupController">
|
||||
<div id="blacklist">
|
||||
<button ng-click="addToBlock()" ng-disabled="isBlocked" id="blacklist_button" class="btn btn-primary" type="submit">BLOCK THIS SITE</button> </div>
|
||||
<!--<div id="whitelist">
|
||||
<input ng-click="testfunc()" id="whitelist_button" class="btn btn-primary" type="submit" value="This shit ballin"> </input></div> -->
|
||||
<body ng-controller="PopupController">
|
||||
<div id="header">
|
||||
<nav class="navbar navbar-static-top ">
|
||||
<button href="" class="btn btn-primary"><span class="glyphicon glyphicon-cog"></span></button>
|
||||
<button ng-click="addToBlock()" ng-disabled="isBlocked" id="blacklist_button" class="btn btn-primary" type="submit">Block this site</button>
|
||||
</nav>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
|
||||
<!doctype html>
|
||||
<html ng-app="app" ng-csp>
|
||||
<head>
|
||||
<title>MAD Reasons</title>
|
||||
<script src="js/shared/bootstrap.min.js"></script>
|
||||
<!-- <script src="js/shared/angular.min.js"></script>
|
||||
<script src="js/shared/ui-bootstrap-ng.min.js"></script>-->
|
||||
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" href="css/main.css">
|
||||
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
|
||||
</head>
|
||||
<body>
|
||||
<div class='modal-header text-center'>
|
||||
<h1> Reason Tracker</h1>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4 text-left">
|
||||
<h2> Good Reasons </h2>
|
||||
</div>
|
||||
<div class="col-md-4 text-center">
|
||||
<h2> Unsorted Reasons </h2>
|
||||
<div ng-repeat="reason in reasons track by $index">
|
||||
<p> {{ reason }} </p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 text-right">
|
||||
<h2> Poor Reasons </h2>
|
||||
</div>
|
||||
|
||||
|
||||
<div class='modal-footer text-center'>
|
||||
<div class='row col-md-12 text-center'>
|
||||
<button class='btn btn-primary' ng-disabled='undoBool' ng-click='undo()'>Clear All</button>
|
||||
<button class='btn btn-danger' ng-click='cancel()'>Close</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||