Merge branch 'improve-follow'
This commit is contained in:
		
						commit
						c5aaaa948f
					
				
					 3 changed files with 20 additions and 6 deletions
				
			
		|  | @ -142,6 +142,7 @@ export default class Follow { | ||||||
|       return style.display !== 'none' && |       return style.display !== 'none' && | ||||||
|         style.visibility !== 'hidden' && |         style.visibility !== 'hidden' && | ||||||
|         element.type !== 'hidden' && |         element.type !== 'hidden' && | ||||||
|  |         element.offsetHeight > 0 && | ||||||
|         Follow.inWindow(window, element); |         Follow.inWindow(window, element); | ||||||
|     }); |     }); | ||||||
|     return filtered; |     return filtered; | ||||||
|  |  | ||||||
|  | @ -4,4 +4,7 @@ | ||||||
|   font-weight: bold; |   font-weight: bold; | ||||||
|   position: absolute; |   position: absolute; | ||||||
|   text-transform: uppercase; |   text-transform: uppercase; | ||||||
|  |   z-index: 100000; | ||||||
|  |   font-size: 12px; | ||||||
|  |   color: black; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -9,15 +9,25 @@ import messages from '../messages'; | ||||||
| consoleFrames.initialize(window.document); | consoleFrames.initialize(window.document); | ||||||
| 
 | 
 | ||||||
| const startFollows = (newTab) => { | const startFollows = (newTab) => { | ||||||
|   let follow = new Follow(window.document, newTab); |   let follow = new Follow(window.document); | ||||||
|   follow.onActivated((element) => { |   follow.onActivated((element) => { | ||||||
|     switch (element.tagName.toLowerCase()) { |     switch (element.tagName.toLowerCase()) { | ||||||
|     case 'a': |     case 'a': | ||||||
|  |       if (newTab) { | ||||||
|  |         // getAttribute() to avoid to resolve absolute path
 | ||||||
|  |         let href = element.getibute('href'); | ||||||
|  | 
 | ||||||
|  |         // eslint-disable-next-line no-script-url
 | ||||||
|  |         if (!href || href === '#' || href.startsWith('javascript:')) { | ||||||
|  |           return; | ||||||
|  |         } | ||||||
|         return browser.runtime.sendMessage({ |         return browser.runtime.sendMessage({ | ||||||
|           type: messages.OPEN_URL, |           type: messages.OPEN_URL, | ||||||
|           url: element.href, |           url: element.href, | ||||||
|           newTab |           newTab | ||||||
|         }); |         }); | ||||||
|  |       } | ||||||
|  |       return element.click(); | ||||||
|     case 'input': |     case 'input': | ||||||
|       switch (element.type) { |       switch (element.type) { | ||||||
|       case 'file': |       case 'file': | ||||||
|  |  | ||||||
		Reference in a new issue