Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: Icon customization in Firefox #95

Open
pcepulionis opened this issue Feb 27, 2021 · 1 comment
Open

feature request: Icon customization in Firefox #95

pcepulionis opened this issue Feb 27, 2021 · 1 comment

Comments

@pcepulionis
Copy link

Blank default icons (or blurry ones) instead of the correct icons are annoying in Firefox. Especially if those webpage are some of the main ones you use with this extension. So I've looked into a code and I have an idea how to fix this problem with favicons provided as base64 images.

  1. In newtab.html we add options_favicon_json as one of the advanced options:
			<fieldset>
				<legend>Favicon JSON</legend>
				<label><textarea id="options_favicon_json"></textarea></label>
			</fieldset>
  1. in newtab.js we are appending favicon_json option in var config dict:
	number_recent: 10,
	icon_provider: 1,
	favicon_json: "{}" // <--- Right here
};
  1. in newtab.js we are modifying function getIcon(node) function to search for icons in dictionary first. If there is no defined domain, then extension is searching icon in selected provider:
		if (domain) {
			var json_dict_temp = getConfig('favicon_json');
			var json_dict = JSON.parse(json_dict_temp);
			for (var d_key in json_dict) {
				var d_value = json_dict[d_key];
				if (domain[1].includes(d_key)) {
					var icon = document.createElement('img');
					icon.style.width = 64;
					icon.style.height = 64;
					icon.src = d_value
					icon.className = 'icon';
					icon.alt = ' ';
					return icon;
				}
			} if (iconProvider == 1) {

and after this, users can assign icon as base64 image based on domain:
image

The only missing part is favicon_json validation to avoid the error in JSON.parse step.
Also, I think my code could be better optimized because for the first time in my life I looked at JavaScript code and it was just a quick test.

I hope this suggestion was helpful and I could add a verification step for JSON.parse step if you would like to implement it.

Btw, I love your extension and have been using it for many years ❤️

@e1a6
Copy link

e1a6 commented Apr 21, 2021

Thank you P. Cepulionis!

I love the extension Isaiah Billingsley has made as well and I've been waiting this feature for a long time but i don't have the knowledge to help like you did...

I hope he will implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants