Commit 141a19b4 authored by Prasanna Venkadesh's avatar Prasanna Venkadesh

Support for Enable/Disable Redirection on toolbar

- The extension icon is now made visible on the toolbar
- clicking on it would toggle the extension to enable/disable.
- introduced new set of icons for disable state as well
parent 5a47ff47
build: clean
zip -r take_diversion.zip ./ -x *.git* README.* Makefile
zip -r take_diversion.zip ./ -x *.git* README.* Makefile LICENSE
mkdir build && mv take_diversion.zip build
clean:
......
/* global variables */
var pattern = "https://www.youtube.com/watch?*";
var redirect_domain = "www.invidio.us";
var enabled = true;
function notify(source, target) {
var title = browser.i18n.getMessage("notificationTitle");
var content = browser.i18n.getMessage("notificationContent", [source, target]);
browser.notifications.create({
"type": "basic",
"iconUrl": browser.extension.getURL("icons/48x48.png"),
"iconUrl": browser.extension.getURL("icons/enabled/64x64.png"),
"title": title,
"message": content
});
}
/* Intercept Youtube Traffic */
function redirect(requestDetails) {
// console.log("Redirecting: " + requestDetails.url);
url = new URL(requestDetails.url);
notify(url.host, redirect_domain)
notify(url.host, redirect_domain);
url.host = redirect_domain;
// console.log("To: " + url.toString());
// console.log("addon enabled: ", url.toString());
return {
redirectUrl: url.toString()
}
}
browser.webRequest.onBeforeRequest.addListener(
redirect,
{urls: [pattern]},
["blocking"]
);
/* Activate/Deactivate */
function toggleState() {
if (enabled == false) {
browser.webRequest.onBeforeRequest.addListener(redirect, {urls: [pattern]},["blocking"]);
browser.browserAction.setIcon({"path": "icons/enabled/48x48.png"});
enabled = true;
} else {
browser.webRequest.onBeforeRequest.removeListener(redirect);
browser.browserAction.setIcon(
{"path": "icons/disabled/48x48.png"});
enabled = false;
}
//console.log("Is addon enabled? ", enabled);
}
browser.webRequest.onBeforeRequest.addListener(redirect, {urls: [pattern]},["blocking"]);
browser.browserAction.onClicked.addListener(toggleState)
......@@ -53,6 +53,41 @@
in2="result91"
id="feComposite889" />
</filter>
<filter
inkscape:label="Inset"
inkscape:menu="Shadows and Glows"
inkscape:menu-tooltip="Shadowy outer bevel"
style="color-interpolation-filters:sRGB"
id="filter891-3">
<feMorphology
result="result1"
in="SourceAlpha"
operator="dilate"
radius="3.6"
id="feMorphology879-6" />
<feGaussianBlur
stdDeviation="3.6"
in="result1"
result="result0"
id="feGaussianBlur881-7" />
<feDiffuseLighting
surfaceScale="-5"
id="feDiffuseLighting885-5">
<feDistantLight
elevation="45"
azimuth="225"
id="feDistantLight883-3" />
</feDiffuseLighting>
<feComposite
in2="result0"
operator="in"
result="result91"
id="feComposite887-5" />
<feComposite
in="SourceGraphic"
in2="result91"
id="feComposite889-6" />
</filter>
</defs>
<sodipodi:namedview
id="base"
......@@ -61,9 +96,9 @@
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="0.35"
inkscape:cx="-325.71429"
inkscape:cy="560"
inkscape:zoom="0.49497475"
inkscape:cx="-53.76191"
inkscape:cy="479.1878"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
......@@ -80,7 +115,7 @@
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
......@@ -88,14 +123,6 @@
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1">
<rect
style="opacity:1;fill:#80d2ff;fill-opacity:1;stroke:none;stroke-width:0.5499317;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers;filter:url(#filter891)"
id="rect815"
width="100"
height="100"
x="-226.02979"
y="84.363083"
ry="21.536993" />
<text
xml:space="preserve"
style="font-style:normal;font-weight:normal;font-size:10.58333302px;line-height:2;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332"
......@@ -117,5 +144,57 @@
height="262.85715"
x="-1871.4286"
y="888.23395" /></flowRegion><flowPara
id="flowPara903"></flowPara></flowRoot> </g>
id="flowPara903" /></flowRoot> <g
id="g833"
inkscape:export-filename="/home/pras/Code/production/web-extensions/take_diversion/icons/disabled/128x128.png"
inkscape:export-xdpi="27.09"
inkscape:export-ydpi="27.09"
transform="translate(349.054,-33.141422)">
<rect
ry="21.536993"
y="69.395988"
x="-296.05441"
height="100"
width="100"
id="rect815"
style="opacity:1;fill:#848484;fill-opacity:1;stroke:none;stroke-width:0.5499317;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers;filter:url(#filter891)" />
<text
id="text828"
y="145.51186"
x="-282.61661"
style="font-style:normal;font-weight:normal;font-size:73.12439728px;line-height:2;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.8281101"
xml:space="preserve"><tspan
style="fill:#ffffff;stroke-width:1.8281101"
y="145.51186"
x="-282.61661"
id="tspan826"
sodipodi:role="line"></tspan></text>
</g>
<g
id="g983"
inkscape:export-filename="/home/pras/Code/production/web-extensions/take_diversion/icons/enabled/128x128.png"
inkscape:export-xdpi="27.09"
inkscape:export-ydpi="27.09"
transform="translate(491.77593,101.56242)">
<rect
ry="21.536993"
y="66.860336"
x="-438.60989"
height="100"
width="100"
id="rect815-9"
style="opacity:1;fill:#3dc554;fill-opacity:1;stroke:none;stroke-width:0.5499317;stroke-linecap:butt;stroke-linejoin:bevel;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers;filter:url(#filter891-3)" />
<text
id="text828-1"
y="142.9762"
x="-425.17209"
style="font-style:normal;font-weight:normal;font-size:73.12439728px;line-height:2;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.8281101"
xml:space="preserve"><tspan
style="fill:#ffffff;stroke-width:1.8281101"
y="142.9762"
x="-425.17209"
id="tspan826-2"
sodipodi:role="line"></tspan></text>
</g>
</g>
</svg>
{
"manifest_version": 2,
"name": "Take Diversion",
"version": "0.2",
"version": "0.3",
"description": "Rewrites domain URL of one site with another.",
"icons": {
"64": "icons/64x64.png"
"48": "icons/enabled/48x48.png",
"64": "icons/enabled/64x64.png",
"128": "icons/enabled/128x128.png"
},
"browser_action": {
"default_icon": {
"48": "icons/enabled/48x48.png",
"64": "icons/enabled/64x64.png",
"128": "icons/enabled/128x128.png"
},
"default_title": "Take Diversion"
},
"permissions": [
"notifications",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment