Monday, March 30, 2020

How to view and edit source code of a Firefox browser extension [Windows]

Find the extension files


In Explorer, open the directory "%APPDATA%\Mozilla\Firefox\Profiles\".
Open the folder that corresponds to your profile (typically a random letter and number combination ending in ".default").
Open the "Extensions" folder.

Duplicate the desired extension file ending in ".xpi"
Rename the duplicate file as a ".zip" file. Extract it to any desired location and open folder contents.

Open "Manifest.json" and view in a text editor like Notepad++ to look for the relevant script files (typically specified in "background":{"scripts": and located in a folder named "js" with the majority of the relevant code in "background.js").

Change the extension


Edit the "js/background.js" file and other relevant source code files to make any changes to the extension.

(Note: the source code in the Javascript file sometimes is condensed into a single line. You can use a online decoder tool such as https://beautifier.io/ to expand the code into multiple lines with conventional spacing for readability.)

When the extension is changed to your liking you will want to use it. You can test it until you close the browser with these steps:

"In Firefox: Open the about:debugging page, click "This Firefox" (in newer versions of Firefox), click "Load Temporary Add-on", then select any file in your extension's directory." - Mozilla Doc

After testing, compress your extension files as a ".zip" or ".xpi" file. (Note: remember NOT to compress the directory containing the files. "Manifest.json" needs to be in the root directory of the compressed file. Otherwise Firefox will report an error that the extension is corrupt!)

Install the modified extension


To have the plugin permanently installed, you must register the add-on with Mozilla and they will digitally sign it to run with any commercial release of Firefox. To avoid having to do this, you can use a Developer, Nightly Build, or Extended Support Release version of Firefox

In Firefox Developer Edition, open the page "about:config" and search for "xpinstall.signatures.required" and double click it to set it to "false". Do the same for "extensions.langpacks.signatures.required" if your extension uses language packs.

On the Firefox menu bar (three horizontal lines icon, top right) go to the "Add-ons" page. To the right of "Manage Your Extensions" click the gear icon and select "Install Add-on from File...". Select your compressed extension file and it will be permanently installed.


Useful Links:


Mozilla Docs - Your First Web Extension How to temporarily test add-on.
Mozilla Docs - Add-on Signing Explains digital signing and how to get around the requirement.
https://beautifier.io/ Javascript decoder for readability

Thursday, March 26, 2020

Pizza on a George Foreman Grill




Tasty! Cooking time 6 minutes to 10 minutes, depending on how firm you want the dough.

Thursday, March 19, 2020

Bookmarklet to download YouTube videos

Drag this link onto your bookmark toolbar. Click it when you're watching a YouTube video.


What goes on when you click the bookmarklet?


The bookmarklet merely opens a new tab and changes the "www.youtube.com" portion of the URL to "www.youtubepp.com". This directs you to a third party website called Y2mate.com that will create a free download link of the YouTube video you are watching.


Javascript code:


javascript:(function(){
    var download_url = window.location.href ;
    var isyt = download_url.indexOf("youtube.com");
    if (isyt != -1 && download_url.indexOf("youtubepp.com") == -1){
        var final = download_url.replace("youtube.com", "youtubepp.com");
        window.open(final);
    }   else {
         alert ("You have to be on youtube.com for this to work!");
}})();

Relevant links:


https://mrcoles.com/bookmarklet/ converts Javascript into a bookmarklet URL
https://meyerweb.com/eric/tools/dencoder/ decodes a URL into Javascript