Skip to content
This repository was archived by the owner on Oct 28, 2022. It is now read-only.

Commit 6647651

Browse files
committed
final polishing of the code, and add a <code> option
1 parent 711802b commit 6647651

File tree

5 files changed

+20
-12
lines changed

5 files changed

+20
-12
lines changed

javascript.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ sf.tags = [
4242
return "<u>" + part2 + "</u>";
4343
}
4444
},
45+
{
46+
"name": "code",
47+
"tag": "code",
48+
"src": "https://raw.githubusercontent.com/Remix-Design/RemixIcon/master/icons/Editor/code-view.svg",
49+
"fillers": ["[code]", "[/code]"],
50+
"formatter": function(part1, part2) {
51+
return "<code>" + part2 + "</code>";
52+
}
53+
},
4554
{
4655
"name": "color",
4756
"tag": "color",
@@ -243,8 +252,8 @@ sf.parse = function(text) {
243252
regex += sf.tags[t].tag;
244253
regex += endBracket;
245254
}
246-
247-
regex = new RegExp(regex, "gm");
255+
256+
regex = new RegExp(regex, "gms");
248257
text = text.replace(regex, sf.tags[t].formatter("$1", "$2"));
249258
}
250259

loader.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Loads javascript onto page
2-
// Dirty method.
3-
{var s = document.createElement('script');
4-
s.src = chrome.extension.getURL('smod.js');
5-
(document.head||document.documentElement).appendChild(s);}
2+
var scripts = ["smod.js", "javascript.js"];
63

7-
{var s = document.createElement('script');
8-
s.src = chrome.extension.getURL('javascript.js');
9-
(document.head||document.documentElement).appendChild(s);}
4+
for (var s = 0; s < scripts.length; s++) {
5+
var script = document.createElement("script");
6+
script.src = chrome.extension.getURL(scripts[s]);
7+
8+
document.head.appendChild(script);
9+
}

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "ScratchFormat",
33
"description": "Rich text editing in Scratch.",
4-
"version": "20.0",
4+
"version": "21.0",
55
"content_scripts": [
66
{
77
"matches": ["https://scratch.mit.edu/users*","https://scratch.mit.edu/studios*", "https://scratch.mit.edu/projects*"],

popup.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<body>
44
<center>
55
<img src="logo.png">
6-
<h2>ScratchFormat 2.0</h2>
6+
<h2>ScratchFormat 2.1</h2>
77
<p>
88
Thank you for using ScratchFormat. <b>To use it, go
99
on a scratch comment editor and click on it.</b> The formatter

smod.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ var smod = {
3030
// This is bad, bad, bad. If anybody can find the native
3131
// way to create popups in Scratch 3.0 React.js, let me know.
3232
dialog3: function(title, text) {
33-
console.log("asd");
3433
var html = `"<div class="ReactModalPortal"><div class="modal-overlay modal-overlay"><div aria-label="Report Comment" class="modal-content mod-report modal-sizes modal-content mod-report" role="dialog" tabindex="-1"><div class="modal-content-close" onclick="this.parentElement.parentElement.parentElement.outerHTML = null;"><img alt="close-icon" class="modal-content-close-img" draggable="true" src="/svgs/modal/close-x.svg"></div><div><div class="report-modal-header" style="background-color: #395c79; box-shadow: inset 0 -1px 0 0 #001fff;"><div class="report-content-label"><span>` + title + `</span></div></div><div class="report-modal-content" style="padding-bottom: 50px;"><div><div class="instructions"><span>` + text +`</span></div></div></div></div></div></div>"</div>`;
3534
document.body.innerHTML += html;
3635
},

0 commit comments

Comments
 (0)