Skip to content

Commit 4184931

Browse files
authored
Completed the project
1 parent e5d86a6 commit 4184931

File tree

7 files changed

+86
-2
lines changed

7 files changed

+86
-2
lines changed

contentscript.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright (c) 2014 The Chromium Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
function buildLinkDisplayContainer() {
6+
var linkDisplayContainer = document.createElement('div');
7+
linkDisplayContainer.setAttribute('id', 'link-display-div');
8+
linkDisplayContainer.setAttribute('class', 'link-display');
9+
10+
return linkDisplayContainer;
11+
}
12+
13+
function showLinkDestination(e) {
14+
var linkHrefText = document.createTextNode(e.target.href),
15+
linkDisplayContainer = buildLinkDisplayContainer();
16+
17+
linkDisplayContainer.appendChild(linkHrefText);
18+
document.body.appendChild(linkDisplayContainer);
19+
}
20+
21+
function hideLinkDestination(e) {
22+
var container = document.getElementById('link-display-div');
23+
container.parentNode.removeChild(container);
24+
}
25+
26+
function moveLinkDisplay(e) {
27+
var container = document.getElementById('link-display-div');
28+
29+
container.style.position = 'absolute';
30+
container.style.left = (e.pageX + 15) + 'px';
31+
container.style.top = (e.pageY + 15) + 'px';
32+
}
33+
34+
function initListeners() {
35+
var anchors = $('a[href^="mailto:"]')
36+
console.log(anchors)
37+
38+
for (var i=0; i<anchors.length;i++) {
39+
var anchor = anchors[i];
40+
if (typeof anchor !== 'object' || typeof anchor.addEventListener === 'undefined') {
41+
continue;
42+
}
43+
var beforeLink = anchor.href
44+
var link = beforeLink.substring(beforeLink.indexOf(":") + 1, beforeLink.indexOf("?"));
45+
$(anchor).removeAttr("href").css("cursor","pointer");
46+
$(anchor).on("click", function(e) {
47+
var r = confirm("Are you sure you want to send an email to " + link + "?")
48+
if (r == true) {
49+
window.open(beforeLink, '_blank');
50+
} else {
51+
}
52+
53+
});
54+
}
55+
}
56+
57+
initListeners();

icon.png

15.3 KB
Loading

icon128.png

15.3 KB
Loading

icon16.png

853 Bytes
Loading

icon48.png

3.52 KB
Loading

jquery.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,30 @@
11
{
22
"manifest_version": 2,
3-
"name": "nomail",
4-
"version": "0.1"
3+
4+
"name": "NoMail",
5+
"description": "Stop accidentally opening your mail client 😭",
6+
"version": "1.0",
7+
8+
"browser_action": {
9+
"default_icon": "icon.png",
10+
"default_title": "Hover text"
11+
},
12+
"icons": {
13+
"16": "icon16.png",
14+
"48": "icon48.png",
15+
"128": "icon128.png"
16+
},
17+
"permissions": [
18+
"*://*/*",
19+
"tabs"
20+
],
21+
"content_scripts": [
22+
{
23+
"matches": ["*://*/*"],
24+
"js": ["jquery.js", "contentscript.js"],
25+
"css": ["style.css"],
26+
"run_at": "document_end",
27+
"all_frames": true
28+
}
29+
]
530
}

0 commit comments

Comments
 (0)