feat: add support for google favicon to quick links

This commit is contained in:
David Ralph
2021-06-18 12:40:46 +01:00
parent cad3f53140
commit 796896571d
3 changed files with 10 additions and 2 deletions

View File

@@ -8,6 +8,7 @@ export default function QuickLinks() {
<>
<h2>{language.title}</h2>
<Switch name='quicklinksenabled' text={window.language.modals.main.settings.enabled} category='quicklinks' element='.quicklinks-container' />
<Checkbox name='quicklinksddgProxy' text={window.language.modals.main.settings.sections.background.ddg_proxy} element='.other' />
<Checkbox name='quicklinksnewtab' text={language.open_new} category='quicklinks' />
<Checkbox name='quicklinkstooltip' text={language.tooltip} category='quicklinks' />
</>

View File

@@ -107,7 +107,7 @@ export default class QuickLinks extends React.PureComponent {
// allows you to add a link by pressing enter
document.querySelector('.topbarquicklinks').onkeydown = (e) => {
e = e || window.event;
let code = e.which || e.keyCode;
const code = e.which || e.keyCode;
if (code === 13 && this.state.showAddLink === 'visible') {
this.addLink();
e.preventDefault();
@@ -125,9 +125,12 @@ export default class QuickLinks extends React.PureComponent {
const tooltipEnabled = localStorage.getItem('quicklinkstooltip');
const quickLink = (item) => {
const useProxy = (localStorage.getItem('quicklinksddgProxy') !== 'false');
const url = useProxy ? 'https://icons.duckduckgo.com/ip2/' : 'https://www.google.com/s2/favicons?sz=32&domain=';
const link = (
<a key={item.key} onContextMenu={(e) => this.deleteLink(item.key, e)} href={item.url} target={target} rel={rel} draggable={false}>
<img src={'https://icons.duckduckgo.com/ip2/' + item.url.replace('https://', '').replace('http://', '') + '.ico'} alt={item.name} draggable={false}/>
<img src={url + item.url.replace('https://', '').replace('http://', '') + (useProxy ? '.ico' : '')} alt={item.name} draggable={false}/>
</a>
);

View File

@@ -226,5 +226,9 @@
{
"name": "photoInformation",
"value": true
},
{
"name": "quicklinksddgProxy",
"value": true
}
]