Habra-editor of comments zero.one
I read this and the idea came up to do something similar for the opera. Of course, it does not shine with the same opportunities, it is not so convenient, but it was also made for itself, I used it myself, I suggest it for everyone to see, maybe it will be useful to someone, maybe someone will bring it to mind ...
In the region, how it works:
In the opera, you can run your scripts when entering pages, this is a very convenient thing, it allows you to get rid of unnecessary blocks and similar evil spirits. In general, I won’t say much, you can connect the script in the settings (tools -> preferences -> content -> Javascript Options [this is the button on the right] -> user JavaScript files [this is the text field at the very bottom])
There you can enter the path from where the opera should take scripts, the browser will scan all the files and try to execute code in them if possible. I try to make my own script for each site, in this case we will have this code:
If you paste this code into any file with the js resolution in the folder specified in the settings, then when you reply to the comment, you get something like this:
As you did for yourself, the possibilities are scarce, but wishes and criticism are welcome, as there was a desire to complete this feature.
PS: To add your button, you need to add an element with fields to the buttons array:
caption - button title (required field)
openTag - opening tag (required field)
closeTag - closing tag (optional field)
correctTag - replacing function in the opening tag "% %% "such a line (optional field)
upd: I don’t measure pipettes with anyone, I just have time and desire to do something useful ...
upd2: opera swears at a script if it is not in utf8 encoding, it does not like Russian in other encodings
In the region, how it works:
In the opera, you can run your scripts when entering pages, this is a very convenient thing, it allows you to get rid of unnecessary blocks and similar evil spirits. In general, I won’t say much, you can connect the script in the settings (tools -> preferences -> content -> Javascript Options [this is the button on the right] -> user JavaScript files [this is the text field at the very bottom])
There you can enter the path from where the opera should take scripts, the browser will scan all the files and try to execute code in them if possible. I try to make my own script for each site, in this case we will have this code:
- if ( location.href.indexOf('habrahabr.ru') !== -1 )
- {
-
- var buttons = [
- { caption: 'pre', openTag: '<pre %%%>', closeTag: '</pre>' },
- { caption: 'A', openTag: '<a href="%%%">', closeTag: '</a>', correctTag: function(){ return prompt("Введи урл"); } },
- { caption: 'user', openTag: '<hh user="%%%" />', correctTag: function(){ return prompt("Введи имя"); } },
- { caption: 'img', openTag: '<img src="%%%" />', correctTag: function(){ return prompt("Введи урл"); } }
- ]
-
- function addText()
- {
- var textarea = $('js-field-comment');
- var button = buttons[event.target.id];
- textarea.value += button.openTag.replace( '%%%', button.correctTag || '' );
- if( button.closeTag )
- {
- textarea.value += button.closeTag;
- }
- }
-
- function drawButtons()
- {
- for( q = 0; q < buttons.length; q++ )
- {
- var element = buttons[q];
-
- var btn = document.createElement( 'input' );
- var textarea = $('js-field-comment');
-
- btn.type = 'button';
- btn.value = element.caption;
- btn.id = q;
-
- btn.onclick = addText;
-
- textarea.parentNode.insertBefore( btn, textarea );
- }
-
- var br = document.createElement('br');
- textarea.parentNode.insertBefore( br, textarea );
-
- }
-
- document.onload = drawButtons;
-
- }
* This source code was highlighted with Source Code Highlighter.
If you paste this code into any file with the js resolution in the folder specified in the settings, then when you reply to the comment, you get something like this:
As you did for yourself, the possibilities are scarce, but wishes and criticism are welcome, as there was a desire to complete this feature.
PS: To add your button, you need to add an element with fields to the buttons array:
caption - button title (required field)
openTag - opening tag (required field)
closeTag - closing tag (optional field)
correctTag - replacing function in the opening tag "% %% "such a line (optional field)
upd: I don’t measure pipettes with anyone, I just have time and desire to do something useful ...
upd2: opera swears at a script if it is not in utf8 encoding, it does not like Russian in other encodings