Coder Social home page Coder Social logo

giuse94 / treccanisearch Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 27 KB

This repository hosts the source code of the "Ricerca su Treccani" Firefox extension, which lets you search the Treccani online corpus directly from the browser address bar.

Home Page: https://addons.mozilla.org/it/firefox/addon/ricerca-su-treccani/

License: The Unlicense

HTML 8.99% TypeScript 91.01%
firefox-extension typescript

treccanisearch's Introduction

About

This repository hosts the source code of the "Ricerca su Treccani" Firefox extension, which lets you search the Treccani online corpus directly from the browser address bar.

Building the extension from source

Source code built on Windows 10 Home Edition, version 22H2 (build 19045.3930), using the following tools:

  • Node.js version 20.11.1;
  • npm version 10.2.4;
  • TypeScript version 5.4.2;
  • @types/firefox-webext-browser package version 120.0.2.

You should be able to build the project on other platforms and with different versions, too. However, TypeScript 3.7 or higher is required as optional property access (?.) and nullish coalescing (??) operators are used.

Prerequisites

To build this project, you first need to download and install Node.js (which includes npm), TypeScript and optionally Git. For more information on how to install these tools, please see the links above.

Get the code

Download this repository or clone it with Git: git clone https://github.com/giuse94/TreccaniSearch.git. If you opted for the download, unzip the folder (extract its content) in a folder of your choice.

Build the project

Open your favourite terminal and set the ts folder (which you find inside the folder you created in the previous step) as your working directory. Download and install this package via npm: npm install @types/firefox-webext-browser. Now you can build the project by simply running tsc. As a result, the package folder will be filled with the JavaScript files you need to run the extension in your browser.

treccanisearch's People

Contributors

giuse94 avatar

Stargazers

plucafs avatar

Watchers

 avatar

treccanisearch's Issues

Add option to hide default suggestion

The default suggestion is not very useful:

  • it reminds you how to use the extension, but only after you activated it by typing the key word;
  • it is not clear what happens when you click on the default suggestion, and it is not documented in the extension description on AMO: if the user did not enter any search term, then it opens the current hint, otherwise it opens the search page for that term. This is somewhat confusing;
  • extensions can only show up to six suggestions in the address bar, including the default one: turning it off would give users one more suggestion.

For these reasons we should add an option to hide the default suggestion.

Built-in ad-block for Treccani website

We could implement an ad-block to remove ads from Treccani website and reduce the number of unnecessary web requests to third-party domains. This will result in cleaner web pages and faster load times.

This feature will be active by default, but there will be an option to turn it on/off.

Add option to give focus to new opened tabs

When the option "Always open search results in a new tab" is set, that tab is opened in background. Add an option to open new tabs in foreground.

Note: in general, when you open an address bar suggestion (not created by the extension) in a new tab, the tab is given focus by the browser; the extension's suggestions are opened in a new background tab instead. Therefore, the extension should follow the browser behaviour to maintain a consistent user experience.

So we have two tasks:

  • change current behaviour so that new tabs are opened in foreground;
  • add an option to open new tabs in background.

Handle lack of Internet connection

When there's no Internet connection, the extension of course can't fetch data from the server and suggestions do not appear in the address bar. If the user is unaware of the problem, he might think that the extension is not working. We could then show a message in the address bar asking to check for Internet connection.

Apart from that, this code throws an exception which should be handled:

fetch(request)
.then(createSuggestionsFromResponse)
.then(addSuggestions);

the Treccani list no longer appears in the search bar

When I installed the extension it worked very well, now it hasn't worked as before for a few months.

In essence, when typing the word, the Treccani list of synonyms, dictionary, etc. no longer appears.... only an element appears which refers to a Treccani page where you can choose whether you want to view the vocabulary, the synonyms or the encyclopedia of that word

Address bar suggestions not shown

Treccani recently switched from http to https as the protocol used to serve its contents. This prevents the extension from receiving responses from the server, because the extension is allowed to receive responses from http://www.treccani.it/ only.

Fortunately, the solution is simple: just add an "s" right after http in the following lines of code:

"permissions": ["http://www.treccani.it/"]

export const BaseURL = "http://www.treccani.it";

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.