How to make extension for Maxthon? Step 2: Bookmarklets

  • "How to make own extension for Maxthon?" is simple guide for ordinary MX users, who need some add-on that they can't find in Extensions Center. I'm sure that MX Team make the most simple extensions sistem (even early extensions for Chrome and sidebar add-ons for Opera were more difficult) and every user can make own simple add-on for the browser. Let's go!



How to make own extension for Maxthon?
Step 2. Bookmarklets

OK, guys! We already know how to make the sidebar addon for Maxthon. But this is not so big achievement: in Vivaldi, Firefox or old Opera you can do this without extensions. Only in Maxthon and new Opera you need extensions for this.

Today we move to the next step in creating of your own extension for Maxthon and make extension with bookmarklet. Bookmarklet is script, which run by click. If you don't understand what I'm talking about, read this.

I will not teach you how to write you own script, because I don't know how. So you have to find the script without my help. Of course, I will show this by example of some script. And I chose TL;DR-ify. This is the services for sharing of excerpts from the text. I wrote about this already. TLDRify has extensions for Google Chrome, Mozilla Firefox and Maxthon. In other browser you can use only bookmarklet. So today we make simple analog of TLDRify for Maxthon Browser. If you don't like this and want to make something else, go in the post about bookmarklets and choose other script. Or find bookmarklet in the web.


1. Create new folder - TLDRify

2. Create icons folder inside TDLRify, add icons as we did on the 1st step

3. Now we'll make def.json file. Oper notepad and write:

[{
     "author": "Michael Spector (original)"
     "email": "webmaster@tldrify.com (about servise)",
     "website": "https://tldrify.com/"
     "date": "15.01.2016",
     "type":"extension",
      "frameworkVersion":"1.0.0",
      "version":"1.0.0",
     "guid": "{1BAEC378-8726-4FD1-8D44-E4AD2A4747C1}",
     "name": " TLDRify"
     "icon": "icon",
     "title": {"en": "TLDRify"},
      "description": {"en": "short URL to selected text"} 

If you passed the 1st step, you know all these lines and now you don't have any questions. Right? This is description of our extension, it is not so much important as the next items:

        "actions": [{
                           "type": "script",
                           "entryPoints": ["toolbar"],
                           "js": ["script.js"]
                           }]

Bookmarklet is script, do you remember? So we use "tipe": "script". And we use "entryPoints": ["toolbar"], because such extensions look better on toolbar. But you can use ["sidebar"] if you want.
Do not forget to close all the brackets!

}]

This is not so difficult, but if you want to check yourself, this is full def.json file for our extension:

[{
     "author": "Michael Spector (original)"
     "email": "webmaster@tldrify.com (about servise)",
     "website": "https://tldrify.com/"
     "date": "15.01.2016",
     "type":"extension",
     "frameworkVersion":"1.0.0",
     "version":"1.0.0",
     "guid": "{1BAEC378-8726-4FD1-8D44-E4AD2A4747C1}",
     "name": " TLDRify"
     "icon": "icon",
     "title": {"en": "TLDRify"},
     "actions": [{
                       "type": "script",
                       "entryPoints": ["toolbar"],
                       "js": ["script.js"]
                       }]
}]

Save this as def.json (if you have no idea how to do this, read step 1 again!)

4. And finally we create this script. Go on tldrify.com, find TLDRify green button, right click and copy URL/shortcut. Open notepad and paste:

javascript:(function(d){d.body.appendChild(d.createElement('script')).src='//tldrify.com/static/js/bookmarklet.min.js?_'+new Date().getTime();})(document);

Save as script.js

5. All done! Just pack TRLDify floder in .mxaddon and install extension in your browser. If you don't know how to do this, why are you still here? Go back to step 1!

That's all, but...

*   *   *

On the first step we made sidebar addon for Google+, so I think now we can add new feature in our extension:

1. Open def.json in Google Plus folder:

[{
       "author": "who developed it",
       "name": "your name",
       "email": "your email",
       "website": "https://plus.google.com/" 
       "date": "15.01.2016",
       "type": "extension",
       "frameworkVersion":"1.0.0",
       "version":"1.0.1",
       "guid": "{ABD3EBCE-FFD0-4D0A-A68A-B93E446310A3}",
       "name": "Google+",
       "icon": "icon",
       "title": {"en": "Google+"},
       "description": {"en": "sidebar addon for Google+"}
       "actions": 
                         [{
                         "type": "panel",
                         "entryPoints": ["sidebar"],
                         "stopOnClose": true,
                         "main": "https://m.google.com/app/basic/",
                         "allowPin": true,
                         "resizable": true,
                         "width": {"default": 480,
                                            "min": 300,
                                            "max": 500},
                         "height": {"default": 720,
                                            "min": 600,
                                            "max": 1200}
                          }]

This is all def.json, only for sidebar window. Let's add share button:

        "actions": [{
                           "type": "script",
                           "entryPoints": ["toolbar"],
                           "js": ["script.js"]
                           }]

And forget about brackets!

}]

2. Open new notepad to create script.js:

javascript:q=(document.location.href);void(open('https://plus.google.com/share?url='+escape(q),'_self','resizable,location,menubar,toolbar,scrollbars,status'));

There are many ways to find or write sharing bookmarklet. I offer you the easiest: use the script from SaveFrom.Net Download Button for Maxthon Browser. This is the one of the first such extensions.

3. Save bookmarklet as script.js, pack Google Plus folder in .mxaddon and install new version of extension in your browser to update it.

It's all... Now you have extension for fast quoting of text and sidebar addon for Google+ with share button. Not so bad for two parts of the guide!

*   *   *

What bookmarklets will we use?

  • share.js
javascript:
var myRuntime = window.external.mxGetRuntime();
var mxTabs = myRuntime.create('mx.browser.tabs');
var TabNum = mxTabs.newTab({url:"https://plus.google.com/share?url="+encodeURIComponent(location.href)+'',
activate: true,position:"afterCurrrent"});



  • search.js
javascript:
selected=window.getSelection();
var myRuntime = window.external.mxGetRuntime();
var mxTabs = myRuntime.create('mx.browser.tabs');
var TabNum = mxTabs.newTab({url:'https://plus.google.com/s/'+encodeURIComponent(selected)+'',
activate: true,position:"afterCurrrent"});



  • page.js
javascript:
var myRuntime = window.external.mxGetRuntime();
var mxTabs = myRuntime.create('mx.browser.tabs');
var TabNum = mxTabs.newTab({url:"https://plus.google.com/me",
activate: true,position:"afterCurrrent"});

*   *   *

P.S.

Tell me, if this will not work.
I did not pack and did not test this add-on and maybe I made a mistake...

That's all...
Share via AddThis or Shareaholic
Translate via GoogleYandexBing or Promt
Original Russian guide
Перевод на русский

Комментарии

Популярные сообщения