[READ-ONLY] Mirror of https://github.com/probablykasper/thumbnail-grabber. Chrome extension for grabbing thumbnails/covers
browser-extension chrome chrome-extension chrome-extention extension
0

Configure Feed

Select the types of activity you want to include in your feed.

Enable extension everywhere

Kasper (Feb 20, 2021, 6:38 PM +0100) 472f670b 2af2c64f

-38
-1
.eslintrc.js
··· 16 16 quotes: ['error', 'single', { avoidEscape: true }], 17 17 'comma-dangle': ['error', 'always-multiline'], 18 18 semi: ['error', 'always'], 19 - // 'no-underscore-dangle': 0, 20 19 'no-unused-vars': ['error', { 'argsIgnorePattern': '^_' }], 21 20 // 'no-unused-vars': [ 22 21 // 'error',
-37
src/background.js
··· 1 - const urlUtil = require('./modules/url-util.js'); 2 - 3 - chrome.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { 4 - if (changeInfo.status == 'complete') { 5 - if (urlUtil.getSite(tab.url)) { 6 - chrome.browserAction.setIcon({ 7 - path: { 8 - '16': 'icon16.png', 9 - '48': 'icon48.png', 10 - '128': 'icon128.png', 11 - }, 12 - tabId: tabId, 13 - }, () => { 14 - // handle error by doing nothing (error occurs when tabs are closed) 15 - if (chrome.runtime.lastError) {window.x;} 16 - }); 17 - } else { 18 - chrome.browserAction.setIcon({ 19 - path: { 20 - '16': 'icon16-gray.png', 21 - '48': 'icon48-gray.png', 22 - '128': 'icon128-gray.png', 23 - }, 24 - tabId: tabId, 25 - }, () => { 26 - if (chrome.runtime.lastError) {window.x;} 27 - }); 28 - } 29 - } 30 - }); 31 - 32 1 function action(tabId, options) { 33 2 injectIfNotAlready(tabId, () => { 34 3 chrome.tabs.sendMessage(tabId, options); ··· 74 43 chrome.contextMenus.create({ 75 44 id: 'open', 76 45 title: 'Open thumbnail', 77 - documentUrlPatterns: urlUtil.matchPatterns, 78 46 contexts: ['page', 'video'], 79 47 }); 80 48 chrome.contextMenus.create({ 81 49 id: 'open-link', 82 50 title: 'Open thumbnail', 83 - targetUrlPatterns: urlUtil.matchPatterns, 84 51 contexts: ['link'], 85 52 }); 86 53 } ··· 88 55 chrome.contextMenus.create({ 89 56 id: 'download', 90 57 title: 'Download thumbnail', 91 - documentUrlPatterns: urlUtil.matchPatterns, 92 58 contexts: ['page', 'video'], 93 59 }); 94 60 chrome.contextMenus.create({ 95 61 id: 'download-link', 96 62 title: 'Download thumbnail', 97 - targetUrlPatterns: urlUtil.matchPatterns, 98 63 contexts: ['link'], 99 64 }); 100 65 } ··· 102 67 chrome.contextMenus.create({ 103 68 id: 'copy', 104 69 title: 'Copy thumbnail', 105 - documentUrlPatterns: urlUtil.matchPatterns, 106 70 contexts: ['page', 'video'], 107 71 }); 108 72 chrome.contextMenus.create({ 109 73 id: 'copy-link', 110 74 title: 'Copy thumbnail', 111 - targetUrlPatterns: urlUtil.matchPatterns, 112 75 contexts: ['link'], 113 76 }); 114 77 }