-
Notifications
You must be signed in to change notification settings - Fork 1
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
About this addon #1
Comments
The first thing to consider is whether it is possible to customize the new tab page. The WebExtensions API Currently, there is another API chrome_url_overrides that changes the new tab entirely to a page provided by the extension. The extension New Tab Override uses this API. With this method, the background image can be changed freely, but the search bar and the top sites will not show (unless you reimplement them in the extension), as the new tab is replaced. Another difficulty is that WebExtensions cannot access the filesystem. Without external programs, the only way to write files is using the built-in download manager, which can put files in the default download folder, or show a dialog where the user chooses the location. Also, there is no API to read the file back without user interaction. Therefore, you have to use other storage methods. Common storage methods of WebExtensions are browser.storage and IndexedDB. You can put the images in one of them in the background script, and then read them in the provided new tab page. To download the images, the background script must access the http://feed.500px.com/500px-best website. Overall I think the download and storage parts are not difficult with the right API. The problem is how to apply it to the new tab page. Do you plan to use chrome_url_overrides (with the disadvantage above), or wait for the |
Ok effectivly i see that the API willn't accept to load local files (because inter-process performances issues apparently). Personally i don't think that is for now the best way as some infos aren't finished.
Ok why not, as u say, it will add to me more dev steps but i don't think that i will become a problem.. I think that i will start on this idea.
Ok, but i said, i don't have knowledges in js linguage, and it appear very strange to me.
Hm hm ok but as i said before, i have no idea on how create my WE, i just have the idea.
I think that i will use the About managing files, i currently use this method supported by Mozilla: https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/FileGuide/MoveCopyDelete Do u know a website on wich i could learn "quickly" the js linguage ? (if we can only use this linguage in WE addon) |
Only JavaScript is supported*. There are some languages that can compile (be converted) to JavaScript e.g. TypeScript used by multithreaded-download-manager, but they are more difficult and less popular than JavaScript. * In theory some other languages like C++ are supported via WebAssembly, but it is still at an early stage of development, and is very difficult to work with WebExtensions. XUL/XPCOM is the underlying technology for legacy extensions, and is not supported by WebExtensions. Many APIs in XUL/XPCOM have no equivalents in WebExtensions, including File IO. In Mozilla docs, the legacy APIs are often listed under Mozilla/Tech/XUL or Mozilla/Tech/XPCOM, while WebExtensions APIs are under Mozilla/Add-ons/WebExtensions. In addition, common HTML/CSS/JS things under Web can usually be used in WebExtensions.
I think Mozilla's MDN docs is a good resource. W3Schools is also popular for beginners. The MDN docs about WebExtensions have some guides and examples. I recommend following them to create and run a simple extension, to see how things work. |
Ok understood.
👍
The MDN docs about WebExtensions have some guides and examples. I recommend following them to create and run a simple extension, to see how things work. Thank you very much i will take a look in them. According my manifest.json, i get this following error when i try to load it temporary in Firefox Beta: And about node.js, it's supported by WE APIs ? |
See #2 for the suggested changes. The error message means at that line, there must be a I suggest using a programming editor, which can show syntax errors clearly. Here is this file on Visual Studio Code: |
About the editor program, u suggest me to install wich one, excluding Viusual Studio, to keep some disk space ? Thank you very much about your fixs 👍 |
Visual Studio Code (VSCode) is a different program from Visual Studio. It is 45 MB to download and 227 MB installed. For smaller alternatives, I heard Sublime Text is good. The free version has no function/time limit but occasionally shows upgrade/register popups. Notepad++ is also recommended. It is free and open source, but Windows only.
It is a different JavaScript environment mainly used in servers and Electron programs. Its APIs cannot be used in extensions. |
I'm actually installing VS 2017 with JS components :)
Ok, it's strange because i have test my manifest.json (i deleted my initial addon folder, download the |
@jingyu9575 Now my WE addon won't be translate, for exemple, i have translated the name and the description in the French and English folder in And i have again the error message "Extension is invalid" from Thank u in advance. |
After several attempt to fix that, i have finally understand the way to make locales to working!
I have also fix this importation issue with the Browser Consol ( Now i begin the serious work :P |
@jingyu9575 I am actually hesitate to use the new Actually i have done to set an img file on the new tab page, but my center I think that i should learn on how to write an clickable menu, it's appear as a abstract way on how it works, i actually read the MDN Web Docs and stackoverflow js scripts exemples, but haven't got knowledges in css and js, it's difficul to understand how to make all them works. Also, i try to apply a translation string to the |
I downloaded the latest source, but the image was not shown at all. You need to move the folder
The problem is whether new images downloaded from 500px will work. Here "an img file in the addon" means the image files we put in the extension's source like "Data URLs" are not regular website URLs, but a specific format for resources. For other theme values, this format is used to apply images not bundled in the extension.
To build a website or an extension, 3 languages are used:
Here, the "Centering the image element" is a layout requirement, so it belongs to the CSS file. First create a CSS file
The CSS file contains style rules, and they are applied to elements in the HTML file. An important question is: how can we write the rules, so that they are only applied to the elements we want? This topic is called "CSS selectors", and some basic methods are:
Therefore, the meaning of Here we need to find the rules that can center the element. Ironically, for old browsers, the rules for centering things can be very difficult and there are multiple-page guides for that (1, 2, 3). Fortunately we only need to support modern browsers (Firefox 57+) here, and in my experience, I suggest the following tools in modern browsers to solve most layout problems:
Centering an element is a simple (single-element) 1D layout problem, so I would use flexbox. Use the
These rules need to be applied to the container. The methods are discussed above. For example, add a class
Finally there are some boilerplate code to force using the entire page height and remove margins (by default the content shrinks to reduce page height):
I have pushed the changes to my fork. If your code still does not work, look there for an example. |
Which menu? Did you mean the popup page of the toolbar button? Just fix the manifest and add content to the HTML file.
The syntax |
I meant fixing the code
See the doc. Toolbar icons are called "browser actions" in WebExtensions. |
Thank you now i see the popup :)
Yeah absolutly i helped myself with the beastify MND WE exemple but really i don't arrive to get my 500px icon in my FF bar with my other addons.. Concerning the choice between the two API to apply the wallpaper as background of the NewTab, i prefere to wait that the new FF API was done to finally deciding on wich i use for that. |
Yes the JS file. For example, to change the text content of the element with id "error-content" to the translated message "description":
Some relevant docs: querySelector, querySelectorAll, textContent, i18n.getMessage
|
@jingyu9575 Hello, i'm trying to make a popup menu with translated items in it: Can u say to me how make it works please ? |
Ok i begin to understand now..
Thank you very much one more time 👍 |
Your Action.js has syntax error, which prevents Firefox from loading the file. The Again, I suggest keeping the extension minimal and removing code from other extensions. That
This code also has syntax error: <a href="About.html" aria-label="aria-labelledby" data-tip-position="under"</a> A <a href="About.html" aria-label="aria-labelledby" data-tip-position="under"></a> The I suggest simplifying the code, and then add the "About" link: <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link href="/css/Action.css" rel="stylesheet" />
<title></title>
</head>
<body>
<a href="Options.html" id="options-link"></a>
<a href="About.html" id="about-link"></a>
<script src="/js/Action.js"></script>
</body>
</html> Here, The line I added In Action.js: document.querySelector('#options-link').textContent = browser.i18n.getMessage('Click_Popup')
document.querySelector('#about-link').textContent = browser.i18n.getMessage('PopupToAbout')
|
Note: semicolons ( document.querySelector('#options-link').textContent = browser.i18n.getMessage('Click_Popup')
document.querySelector('#about-link').textContent = browser.i18n.getMessage('PopupToAbout') is equivalent to: document.querySelector('#options-link').textContent = browser.i18n.getMessage('Click_Popup');
document.querySelector('#about-link').textContent = browser.i18n.getMessage('PopupToAbout'); Some people use semicolons, while some people do not use them. |
Ok, and as i use this addon, it could make error(s).
The student will listen to the teacher on the subject 💯
Fixed, thanks!
Noted.
Again more crucial HTML rules that i discover thanks to you! |
@jingyu9575 Hello, I'm currently trying to center a
Actually it's displaied like that for me: And about my strings elements (the menu), i get in the Navigation console the following error: I understand by this message that the Or maybe that the location of the |
I only saw a blank page, and did not see the TypeError. Have you uploaded the code to this repo? If you are not using the Team Explorer in Visual Studio: this is a feature to integrate project with version control tools and websites such as GitHub. Click the "Open in Visual Studio" button in GitHub. Visual Studio will open and Team Explorer will ask for a new location to download the repo. In this new project, you can commit the local changes and push them to GitHub. |
Hello, thanks for answer. And thank you about the hability to push directly my changes from VS to my git 👍 I want to know how to adding a new text link to a local html file, i tried to changing the |
No, Team Explorer only asks for the GitHub account to push the changes. The Community (Free) edition of Visual Studio requires Microsoft account though.
In the JS file, this line is a CSS rule (the spaces inside There are many syntax errors in the HTML file.
I still suggest rewriting the HTML file, without the parts from other extensions. For a quick introduction to the HTML syntax and structure, see this tutorial. Basically, HTML consists of tags. For example: <p>My first paragraph.</p>
Attribtes are written in the start tag, and provide additional information for the tags. The browsers use attributes such as <a href="About.html">My link</a> This Tags can contain other tags: <p>
<a href="1.html">First link</a>
<a href="2.html">Second link</a>
</p> This is a paragraph, which has two links. Whitespaces and newlines are equivalent, and the links may show horizontally. Some tags only use start tag without end tag, such as The basic structure of a HTML file is: <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html> Except the doctype, everything is in a I suggest starting from this minimal file, including the JS and CSS with |
@jingyu9575 You gave me a lot of information, and i thank u again for that but i don't understand at all how to use these languages for an interaction with Firefox, especially the HTML tags. I try to help myself from sources of other modules except that each time different display and coding methods are used, which loses me even more. I basically understood how base tags like div, span work, but in my case, i don't understand how to create a text link that will appear in my popup in Firefox. I also don't understand much about the step-by-step operation of this part there (i can guess, but since the JS language sounds particularly raw to understand...). The CSS part is the part i understand the most easily (maybe it's also the simplest part, only you will be able to say yes or no). Overall, and especially in my case, i don't understand how i will be able to tell Firefox to display a link to a local HTML file (Options.html) using split tags, span, and others via the I must be very boring on this subject, but knowing me, it's the beginning that is the hardest :) Maybe that u have already answer me on several points, sorry in advance. |
Think HTML tags as a way to mark text. For example: Mozilla Firefox is a web browser.
It is developed by Mozilla Foundation. This is a simple plain text, without any formatting or different elements. You can use the Tryit Editor to see the result. Copy this text to the left box and click "Run", and you will see the text is shown directly without any effects. Now I want to mark the first two words "Mozilla Firefox" as bold. In modern document editors I can just select them and click the "B" icon, but in HTML everything must be written as code. Therefore people invented a way to mark the text: putting <b>Mozilla Firefox</b> is a web browser.
It is developed by Mozilla Foundation. Update the code in the Tryit Editor to see the effect. Next, I want to change "Mozilla Foundation" to a link to mozilla.org. Similarly, people invented a tag <b>Mozilla Firefox</b> is a web browser.
It is developed by <a>Mozilla Foundation</a>. However, this does not have any effect yet, because the browser does not know the link's address. Therefore, people came up with attributes, and invented an attribute called "href" to represent the address. <b>Mozilla Firefox</b> is a web browser.
It is developed by <a href="https://www.mozilla.org">Mozilla Foundation</a>. Next, I want to add a the Firefox logo at the beginning. There is a tag <img src="https://www.mozilla.org/media/img/firefox/favicon.e6bb0e59df3d.ico">
<b>Mozilla Firefox</b> is a web browser.
It is developed by <a href="https://www.mozilla.org">Mozilla Foundation</a>. Finally, I can add a title with the <h1>Firefox</h1>
<img src="https://www.mozilla.org/media/img/firefox/favicon.e6bb0e59df3d.ico">
<b>Mozilla Firefox</b> is a web browser.
It is developed by <a href="https://www.mozilla.org">Mozilla Foundation</a>. We see that HTML tags are just a way to mark text. These days we have CSS, a powerful tool for layout and styling, so some tags for styling such as The tags I suggest reading a HTML tutorial such as this, to get familiar with the commonly used tags and attributes. |
@jingyu9575 Hello, i don't know how to parse my string message from a I attach my Can u say me what i make wrong ? EDITI have finally fix them, but now i get: EDIT 2Fixed, the locales |
Hello, i'm currently looking into API u suggested to me in your first answer. Apparently, regarding in the compatibility section of About I don't really have any ideas on how i should start writing at javascript level, but internet is also made for it. Concerning your suggestion to store images in a database file (IndexedDB) with a unit identification by key, i think that the first API you mentioned (browser.storage) might be the easiest to start with? As for the API that i will use in Firefox, either I think i should start with the first one, |
The link shows that Fetch API is compatible with Firefox 39+, and the signal feature (ability to abort requests) is compatible with Firefox 57+. I think it is enough for the extension. (What version do you plan to support?) "Streaming response body" means downloading large files progressively and getting partial data. For small files that can be downloaded completely, this feature is not required. I've considered using this API in multithreaded-download-manager instead of StreamFilter which is related to the high CPU usage, but it is not officially supported now (requires an about:config change) and has some crash problems. In my opinion, Fetch is easier to use than the old XMLHttpRequest API. Of course XMLHttpRequest is also supported in modern browsers and can also be used.
Yes, I think
The link is for the New Tab Page colors. This is the tracking bug of
I agree. There is a syntax error in Actions.html (this line). The browser can recover from it but the result is not correct. In this case, the error does not affect other tags, so you may not see any effects, but I suggest avoiding syntax errors in general. |
Actually i don't know precisely wich version i will set for the
Another problem i'm gonna face so if i understand you correctly?
So if
Question a little useless but I'm going to ask you: do you think that its implementation will one day be officialized as WebExtension or is it unlikely?
Thank u. I'm getting to pull the fix, a fix for my Feeling a lot more comfortable with the HTML and CSS with my practise, i'm looking on how the JS language work, i will make the A last thing: u could find some strange things on my part and various errors probably not impacting the general rendering, i encountered some difficulties and rewrite some parts of the HTML code to make it work as i wanted, but i managed to get the result i wanted. I'm currently looking on my |
@jingyu9575 Also, i don't arrive to hide my I'm currently trying by this method: My html:The area to hide by default:And there is my actual js attempt:I have take my attempt from this thread: https://stackoverflow.com/questions/16712941/display-div-if-a-specific-select-option-value-is-selected Would you have an idea on what i made wrong please ? |
I think "Basic support" of the fetch API is enough for the extension (loading the 500px web page and downloading images). There is no need for the "Streaming response body" feature.
I guess it is likely to be officialized. The assignee Tim Nguyen is a very active developer of WebExtensions themes.
The code first gets a specific You want to test the local_update option here (comparing its value with the selected value), so you want the code Another problem is that all your options have the same value, so the method of comparing the values does not work. Change the values to be distinct (they do not need to be numbers). One of the
This line creates a new variable, but it lacks the |
OK i will take a look after i will finishing my settings page.
Great, it's could be nice !
Understood, so i have edit my html like that: But it don't work
I have read all my id strings inside the
Do u say that even if all my id values and js script is good, the result will never happen because the answer at: https://stackoverflow.com/questions/16712941/display-div-if-a-specific-select-option-value-is-selected is wrong ? |
The JS code should be inside If it still does not work, please upload the code so I can download and test.
It will work in non-strict mode. If you don't use those keywords, the line Strict mode JS bans this way to create global variables, making this code to throw errors. It is recommended to create local variables instead, by using one of
This way, the variable only exists locally, so if another function happens to use the same name, it will not be affected. |
I just have upload my last changes on my git, thanks to tell me what's wrong in my file(s). |
@jingyu9575
I don't understand this error because i have write the links of my I just have commit all my last changes on the repo, i have a question: There is possible to add some html elements at right of the vertical separator (vl element), where my pointer is ? Also tomorrow i will fix my options page, because since i implement the option page in newtab feature, i have see that some elements aren't optimized for a good reading. EDIT: Alternativly, when u will see my error(s) for the new option in my settings page, i want to edit dynamicaly CSS properties by js or css (if possible). => When the checkbox for displaying the Options page in a new tab is enabled, uncomment a css value like: |
My extension uses a complicated
This error is because you are using the
you can just use
The other two errors are in Firefox's internal file "ext-webNavigation.js" and not related to the extension. I'd modify "Popup.js" to: document.querySelector('#clickSettings').addEventListener('click', async (event) => {
event.preventDefault();
if ((await browser.storage.local.get()).showOptionsInDedicatedTab)
void browser.tabs.create({ url: browser.runtime.getURL('/html/Options.html') });
else
void browser.runtime.openOptionsPage();
}); The id of the link and the options page URL are different in your extension. Also, the default action of the link (opening In addition, this
You are right. The layout should be written in the CSS. In your existing CSS:
So one of the approaches is to add another div with |
For clarity, let's use the following simplified HTML as an example : <div id="container">
<div id="left-pane">Left pane</div>
<div id="separator"></div>
<div id="right-pane">Right pane</div>
</div> and the desired layout is:
First, set
That's it: #container {
display: flex;
flex-direction: row;
}
#left-pane, #right-pane {
flex: 1;
}
#separator {
background-color: blue;
width: 6px;
} See the result in the TryIt Editor (click "Run"). |
Thanks a lot for your infos. I have edit
I have following your exemple, i'm arrived to make my ids texts area to be moved on the middle of my page, but not the git img, also here idk there is/are my error(s). What's weird is that i followed your model by replacing my container, my ids and my divs' names, but it almost didn't work properly. I have push all my changed files on the repo to check it.. |
Did you include this file in Actions.html?
First check the syntax. CSS can be written in the CSS file or in With your ids, the CSS should be: #container {
display: flex;
flex-direction: row;
}
#about-mdn, #about-dev {
flex: 1;
}
.vl {
background-color: blue;
width: 6px;
} |
I think Popup.js adds a click event on the clickSettings link: if the You can also move this event code to Actions.js and remove Popup.js. Remember to update this setting when the checkbox is toggled. You need a
I think the code in the repo is out of sync. |
For the browser.storage.local.set({kitten, monster})
.then(setItem, onError); or use async function and await: // in an async function
await browser.storage.local.set({kitten, monster}) These asynchronous-related things are complex and difficult to explain here, so I suggest google-ing some tutorials. By the way, the API theme_ntp_background is unassigned by the developer. |
Here @jingyu9575,
We can continue to speack here to avoid spamming your repo.
Don't hesitate to suggest to me some methods
Thank you in advance :)
The text was updated successfully, but these errors were encountered: