File tree 7 files changed +108
-0
lines changed
7 files changed +108
-0
lines changed Original file line number Diff line number Diff line change
1
+ A simple add-on that adds a link to the longdesc under images that provides one.
2
+
3
+ Maybe you want to look at this other extension for longdesc https://addons.mozilla.org/en-US/firefox/addon/longdesc/
4
+
5
+ The source code lives at https://github.com/Rik/longdesk
6
+
7
+ * Disclaimer:* I have no opinion on whether the longdesc attribute should or should not exist.
8
+ 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.
9
+ This add-on has only been tested on http://www.nota-bene.org/Mise-en-abyme-a-carreaux
10
+
11
+ Also, this is my first add-on ever so…
Original file line number Diff line number Diff line change
1
+ ( function ( ) {
2
+ var imgs = document . querySelectorAll ( 'img[longdesc]' ) ;
3
+
4
+ if ( imgs . length == 0 )
5
+ return ;
6
+
7
+ self . postMessage ( 'load-styles' ) ;
8
+ self . on ( 'message' , function ( data ) {
9
+ if ( data . styles ) {
10
+ var style = document . createElement ( 'style' ) ;
11
+ style . appendChild ( document . createTextNode ( data . styles ) ) ;
12
+ document . head . appendChild ( style ) ;
13
+ }
14
+ } )
15
+
16
+ for ( var i = 0 , il = imgs . length ; i < il ; i ++ ) {
17
+ var img = imgs [ i ] ;
18
+
19
+ var a = document . createElement ( 'a' ) ;
20
+ a . classList . add ( 'longdesc-addon-link' ) ;
21
+ a . href = imgs [ i ] . getAttribute ( 'longdesc' ) ;
22
+ a . appendChild ( document . createTextNode ( 'Description' ) ) ;
23
+
24
+ var top = img . offsetTop + img . height ;
25
+ a . style . top = top + "px" ;
26
+ a . style . left = img . offsetLeft + "px" ;
27
+
28
+ img . parentNode . insertBefore ( a , img . nextSibling ) ;
29
+ }
30
+ } ) ( ) ;
Original file line number Diff line number Diff line change
1
+ .longdesc-addon-link {
2
+ position : absolute;
3
+ color : black;
4
+ background : white;
5
+ border : 1px solid black;
6
+ border-top : 0 ;
7
+ border-radius : 0 0 5px 5px ;
8
+ }
Original file line number Diff line number Diff line change
1
+ The main module is a program that creates a widget. When a user clicks on
2
+ the widget, the program loads the mozilla.org website in a new tab.
Original file line number Diff line number Diff line change
1
+ const pageMod = require ( "page-mod" ) ;
2
+ const data = require ( "self" ) . data ;
3
+
4
+ exports . main = function ( ) {
5
+ pageMod . PageMod ( {
6
+ include : [ "*" ] ,
7
+ contentScriptFile : data . url ( 'pagemod.js' ) ,
8
+ onAttach : function onAttach ( worker ) {
9
+ worker . on ( 'message' , function ( message ) {
10
+ if ( message == 'load-styles' ) {
11
+ worker . postMessage ( { styles : data . load ( 'style.css' ) } ) ;
12
+ }
13
+ } ) ;
14
+ }
15
+ } ) ;
16
+ }
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " longdesk" ,
3
+ "license" : " WTFPL http://sam.zoy.org/wtfpl/" ,
4
+ "author" :
" Anthony Ricaud <[email protected] " ,
5
+ "version" : " 0.1" ,
6
+ "fullName" : " longdesk" ,
7
+ "id" : " jid1-KN9CeRzPwYe6Rw" ,
8
+ "description" : " A simple add-on that adds a link to the longdesc under images that provides one."
9
+ }
Original file line number Diff line number Diff line change
1
+ const main = require ( "main" ) ;
2
+
3
+ exports . test_test_run = function ( test ) {
4
+ test . pass ( "Unit test running!" ) ;
5
+ } ;
6
+
7
+ exports . test_id = function ( test ) {
8
+ test . assert ( require ( "self" ) . id . length > 0 ) ;
9
+ } ;
10
+
11
+ exports . test_url = function ( test ) {
12
+ require ( "request" ) . Request ( {
13
+ url : "http://www.mozilla.org/" ,
14
+ onComplete : function ( response ) {
15
+ test . assertEqual ( response . statusText , "OK" ) ;
16
+ test . done ( ) ;
17
+ }
18
+ } ) . get ( ) ;
19
+ test . waitUntilDone ( 20000 ) ;
20
+ } ;
21
+
22
+ exports . test_open_tab = function ( test ) {
23
+ const tabs = require ( "tabs" ) ;
24
+ tabs . open ( {
25
+ url : "http://www.mozilla.org/" ,
26
+ onReady : function ( tab ) {
27
+ test . assertEqual ( tab . url , "http://www.mozilla.org/" ) ;
28
+ test . done ( ) ;
29
+ }
30
+ } ) ;
31
+ test . waitUntilDone ( 20000 ) ;
32
+ } ;
You can’t perform that action at this time.
0 commit comments