Add Interface and Badged

This commit is contained in:
Kevin Röbert 2017-08-19 00:30:47 +02:00
parent a3128aa0a6
commit 781a4f648a
4 changed files with 45 additions and 121 deletions

View File

@ -7,6 +7,8 @@ var data = [];
var providers = [];
var prvKeys = [];
var globalStatus;
var badges = [];
var tabid = 0;
/**
* Initialize the JSON provider object keys.
@ -124,6 +126,10 @@ function Provider(_name,_completeProvider = false){
rules.push(rule);
};
/**
* Set the rules for the provider
* @param String _rules RegEx as string
*/
this.setRules = function(_rules) {
rules = _rules;
};
@ -191,6 +197,12 @@ function removeFieldsFormURL(provider, request)
if(bevorReplace != url)
{
if(badges[tabid] == null)
{
badges[tabid] = 0;
}
browser.browserAction.setBadgeText({text: (++badges[tabid]).toString(), tabId: tabid});
changes = true;
}
}
@ -261,6 +273,30 @@ function clearUrl(request)
}
};
/**
* Call by each tab is closed.
*/
function handleRemoved(tabId, removeInfo) {
delete badges[tabId];
}
/**
* Call by each tab is closed.
*/
browser.tabs.onRemoved.addListener(handleRemoved);
/**
* Call by each tab change to set the actual tab id
*/
function handleActivated(activeInfo) {
tabid = activeInfo.tabId;
}
/**
* Call by each tab change.
*/
browser.tabs.onActivated.addListener(handleActivated);
/**
* Call by each Request and checking the url.
*

View File

@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "ClearURLs",
"version": "0.4",
"version": "0.5",
"author": "Kevin R., Arne S.",
"description": "Remove tracking elements form URLs. ",
"homepage_url": "https://github.com/KevinRoebert/ClearUrls",

View File

@ -2,6 +2,7 @@
<html>
<head>
<title>ClearURLs Add-on</title>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="popup_style.css">
<link rel="stylesheet" type="text/css" href="switchButtons.css">
<script src="jquery-3.2.1.min.js"></script>
@ -9,37 +10,13 @@
</head>
<body>
<div id="main">
<div class="header">ClearURLs 0.4</div>
<div class="header">ClearURLs 0.5</div>
<div id="content">
<div id="default">
<div id="global">
Enable globally:<br>
<button id="globalStatus" class="status statusEnabled"></button>
</div>
<div id="individual">
Enable individually:<br>
<div id="presets">
<label class="switch">
<input type="checkbox">
<span class="slider round"></span>
<label>Google</label>
</label>
<!--<div class="element"><button class="switch switchEnabled"></button><div class="textElement">---placeholder---</div><br></div>-->
<!-- <button id="exception" class="enable" onclick="handleException()">Enable on page</button><br> -->
</div>
</div>
</div>
<div id="custom">
My rules (advanced):<br>
<div id="rules">
---placeholder---<br>
</div>
<div id="addRuleOuter">
Add new rule:<br>
<div id="addRuleInner">
<div id="addRuleField"><input type="text"></div><button id="addRuleBtn"><img src="plus.png"></button>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,8 +1,9 @@
body {
margin: 0;
top: 0;
background: #fff;
min-width: 500px;
max-width: 600px;
min-width: 180px;
max-width: 180px;
font-family: "Arial";
}
@ -11,13 +12,8 @@ img {
margin: auto;
}
#main {
max-width: 500px;
max-height: 400px;
top: 0;
overflow-y: auto;
overflow-x: hidden;
white-space: nowrap;
@ -36,15 +32,12 @@ img {
color: #dedede;
font-size: 11pt;
text-align: center;
top: 0;
padding: 2px 0px 2px 0px;
margin: 5px 0px 5px 0px;
}
#default::after, #presets::after, .element::after, #rules::after, #addRuleOuter::after, #addRuleInner::after {
#default::after {
content: " ";
clear: both;
display: table;
@ -52,7 +45,6 @@ img {
#global {
width: 50%;
float: left;
}
.status {
@ -75,76 +67,6 @@ img {
background-image: url("icon128_g.png");
}
#individual {
width: 50%;
float: right;
}
#presets, #rules, #addRuleOuter {
margin: 10px 0px 0px 10px;
}
#custom {
margin-top: 20px;
width: 100%;
display: block;
float: left;
}
#addRuleInner {
margin-top: 5px;
}
#addRuleField {
overflow: hidden;
float: left;
width: calc(100% - 55px);
height: 25px;
border-radius: 3px;
height: 30px;
}
#addRuleField input {
width: 100%;
height: 100%;
border: none;
background-color: #d7d6db;
-webkit-transition: .4s;
transition: .4s;
padding-left: 10px;
padding-right: 10px;
}
#addRuleField input:focus {
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
#addRuleBtn {
width: 45px;
padding: 3px 0px 3px 0px;
float: right;
background-color: #b5e61d;
border: none;
border-radius: 3px;
height: 30px;
}
#addRuleBtn:active {
background-color: #96d160;
}
.switch {
margin-right: 10px;
width: 50px;
@ -152,15 +74,4 @@ img {
float: left;
background: none;
border: none;
}/*
.switchEnabled {
background-image: url("switchEnabled.png");
}
.switchDisabled {
background-image: url("switchDisabled.png");
}*/
.textElement {
clear: right;
text-overflow: ellipsis;
}