-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ae35eb0
Showing
7 changed files
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
A simple add-on that adds a link to the longdesc under images that provides one. | ||
|
||
Maybe you want to look at this other extension for longdesc https://addons.mozilla.org/en-US/firefox/addon/longdesc/ | ||
|
||
The source code lives at https://github.com/Rik/longdesk | ||
|
||
*Disclaimer:* I have no opinion on whether the longdesc attribute should or should not exist. | ||
I'm just tired of having to look through the source code every time I want to see a friend's explanation of a picture. | ||
This add-on has only been tested on http://www.nota-bene.org/Mise-en-abyme-a-carreaux | ||
|
||
Also, this is my first add-on ever so… |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(function () { | ||
var imgs = document.querySelectorAll('img[longdesc]'); | ||
|
||
if (imgs.length == 0) | ||
return; | ||
|
||
self.postMessage('load-styles'); | ||
self.on('message', function (data) { | ||
if (data.styles) { | ||
var style = document.createElement('style'); | ||
style.appendChild(document.createTextNode(data.styles)); | ||
document.head.appendChild(style); | ||
} | ||
}) | ||
|
||
for (var i=0, il=imgs.length; i < il; i++) { | ||
var img = imgs[i]; | ||
|
||
var a = document.createElement('a'); | ||
a.classList.add('longdesc-addon-link'); | ||
a.href = imgs[i].getAttribute('longdesc'); | ||
a.appendChild(document.createTextNode('Description')); | ||
|
||
var top = img.offsetTop + img.height; | ||
a.style.top = top + "px"; | ||
a.style.left = img.offsetLeft + "px"; | ||
|
||
img.parentNode.insertBefore(a, img.nextSibling); | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.longdesc-addon-link { | ||
position: absolute; | ||
color: black; | ||
background: white; | ||
border: 1px solid black; | ||
border-top: 0; | ||
border-radius: 0 0 5px 5px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
The main module is a program that creates a widget. When a user clicks on | ||
the widget, the program loads the mozilla.org website in a new tab. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const pageMod = require("page-mod"); | ||
const data = require("self").data; | ||
|
||
exports.main = function() { | ||
pageMod.PageMod({ | ||
include: ["*"], | ||
contentScriptFile: data.url('pagemod.js'), | ||
onAttach: function onAttach(worker) { | ||
worker.on('message', function(message) { | ||
if (message == 'load-styles') { | ||
worker.postMessage({styles: data.load('style.css')}); | ||
} | ||
}); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"name": "longdesk", | ||
"license": "WTFPL http://sam.zoy.org/wtfpl/", | ||
"author": "Anthony Ricaud <anthony@ricaud.me", | ||
"version": "0.1", | ||
"fullName": "longdesk", | ||
"id": "jid1-KN9CeRzPwYe6Rw", | ||
"description": "A simple add-on that adds a link to the longdesc under images that provides one." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const main = require("main"); | ||
|
||
exports.test_test_run = function(test) { | ||
test.pass("Unit test running!"); | ||
}; | ||
|
||
exports.test_id = function(test) { | ||
test.assert(require("self").id.length > 0); | ||
}; | ||
|
||
exports.test_url = function(test) { | ||
require("request").Request({ | ||
url: "http://www.mozilla.org/", | ||
onComplete: function(response) { | ||
test.assertEqual(response.statusText, "OK"); | ||
test.done(); | ||
} | ||
}).get(); | ||
test.waitUntilDone(20000); | ||
}; | ||
|
||
exports.test_open_tab = function(test) { | ||
const tabs = require("tabs"); | ||
tabs.open({ | ||
url: "http://www.mozilla.org/", | ||
onReady: function(tab) { | ||
test.assertEqual(tab.url, "http://www.mozilla.org/"); | ||
test.done(); | ||
} | ||
}); | ||
test.waitUntilDone(20000); | ||
}; |