Skip to content
TORNLIFE More

[SCRIPT] Torn Notepad++

Started by Bug [1455582] Committee on in Tools & Userscripts.

24 replies · 995 views · thread synced · 4 days ago · View on torn.com
About this thread

Posts archived: 25 / 25 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
25
Discussion span
→
Authority score
63 / 100
Historical score
48 / 100
Story score
43 / 100
Engagement score
70 / 100

People posting, likes and official posts are not counted for this thread yet: on threads longer than one page they come from a periodic pass over the archive, which has not covered it.

Most-liked replies

Bug [1455582] Committee Committee

Introducing the advanced notebook, with formatting such as bold, italic, underlined and coloured fonts. With the "code" tab however, you could write in nearly any HTML from tables to pretty pictures (disabled by default). You can customize what menu's are shown on line 38, I whipped this up in an hour so don't expect anything elegant, enjoy :)



[image: i.imgur.com]



Script Source
// ==UserScript==
// @name Torn Notepad++
// @include *.torn.com/*
// @require https://gist.github.com/raw/2625891/waitForKeyElements.js
// @require https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.6.5/tinymce.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.6.5/themes/modern/theme.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.6.5/plugins/code/plugin.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.6.5/plugins/textcolor/plugin.min.js
// @grant GM_addStyle
// ==/UserScript==

GM_addStyle('.mce-popover{ z-index:1000000!important; }');
GM_addStyle('.d .mce-tinymce .mce-container-body>.mce-edit-area.mce-panel iframe{ max-height: 10000px!important; min-height: 10px!important; }');

function onUpdate(mutations) {
tinymce.activeEditor.theme.resizeTo(null, mutations[0].target.offsetHeight - 80);
}

waitForKeyElements("textarea[class^='edit-note']", function() {
for (var i = tinymce.editors.length - 1 ; i > -1 ; i--) {
var ed_id = tinymce.editors.id;
tinyMCE.execCommand("mceRemoveEditor", true, ed_id);
}
var rawNotepad = document.querySelector("textarea[class^='edit-note']");
var container = rawNotepad.parentNode.parentNode;
new MutationObserver(onUpdate).observe(container, {attributes: true});
tinymce.baseURL = 'js/script/lib/tinymce/';
tinymce.init({
selector:"textarea[class^='edit-note']",
menubar: false,
statusbar: false,
nowrap: false,
height: container.offsetHeight - 80,
force_br_newlines : true,
force_p_newlines : false,
forced_root_block : '',
resize: true,
plugins: 'code textcolor',
toolbar: 'bold underline italic forecolor backcolor | removeformat', // | code strikethrough superscript subscript
setup: function (editor) {
editor.on('blur', function () {
editor.save();
rawNotepad.style.display = "";
rawNotepad.focus();
rawNotepad.blur();
rawNotepad.style.display = "none";
});
}
});
});
Bug [1455582] Committee Committee
Updated, I've added text colours & highlighting! To make space for this I've removed the code & strike through options, although you can add these back yourself by editing line 33. I've also adjusted the height of the window to allow for the extra buttons and remove the scrollbar since it was bugging me. Have fun :)

BEFORE & AFTER

[image: i.imgur.com][image: i.imgur.com]

Bug [1455582] Committee Committee
Oh? Does it save on the new code? The save should be triggered by clicking anywhere outside the notepad. What browser/operating system are you using? Any errors in the console?
GamesDean [2266320]
I haven't tried the new code yet. I wasn't sure if I was either doing something wrong or maybe it was the older code. The regular notepad auto saves and I'd close it and it would be revert to before I edited it.

I use Android and Yandex
Phool [2176935]
This looks great!
Dumb question - how do I add the script to chrome?

Edit - problem solved - thanks Bug and Hardy =)
Bug [1455582] Committee Committee
Install a chrome extension such as greasemonkey or tampetmonkey and click create a new script then paste the code inside :)
Bug [1455582] Committee Committee
The regular notepad auto saves and I'd close it and it would be revert to before I edited it.

Wait, so without the script it reverts itself?
Bug [1455582] Committee Committee
After changing it in the settings you'll need to refresh the page, does that fix the issue?
GamesDean [2266320]
Sorry. I realize that was two different points run together. The regular notepad autosaves. When I ran the notepad++ the first time with the old code, it wouldn't ever save what I had done (bolded or any format changes). It would revert to when I opened it without the changes saved.

Edit: I have since tried the new script and it works fine for me. It does most of what you want to do, which is a far upgrade from the standard notepad.
SkinnyPeen [2176021]
was also bugging me, thanks :P


Also, I noticed that when you fullscreen the notepad, then minimise it, it reverts back to the /slightly/ smaller div that scrolls offscreen. (basically after being in expanded mode, it goes back to the first screenshot you posted)
Bug [1455582] Committee Committee
This issue should now be fixed, if you copy the new code it should update the height live too which will fix the issue Cum [2176021] mentioned :)