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

Commit ea5b618

Browse files
committed
Bug Fixes, add smod.js
1 parent 2439632 commit ea5b618

File tree

5 files changed

+66
-2
lines changed

5 files changed

+66
-2
lines changed

ScratchFormat.zip

-23.4 KB
Binary file not shown.

javascript.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ var formatter;
44
// Everything is customizable here.
55
// (local images don't work yet, but who cares.
66
// this is the internet.)
7+
var version = 3;
8+
if (document.body.children[0].id == "pagewrapper") {
9+
version = 2;
10+
}
11+
712
var tags = [
813
{
914
"name": "bold",
@@ -92,7 +97,10 @@ setTimeout(function() {
9297
if (tags[t].help) {
9398
icon.style.float = "right";
9499
icon.onclick = function() {
95-
window.open("https://github.com/ScratchFormat/ScratchFormat2/issues");
100+
smod.dialogText("ScratchFormat Help", `
101+
<a href="https://github.com/ScratchFormat/ScratchFormat2/issues" style="color: #12b1e4;">Report issues at our Github</a>
102+
If you do not own a Github account, simply comment on my profile <a href="https://scratch.mit.edu/users/pufflegamerz/" style="color: #12b1e4;">@pufflegamerz</a>
103+
`, version);
96104
}
97105

98106
formatter.appendChild(icon);

loader.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{var s = document.createElement('script');
2+
s.src = chrome.extension.getURL('smod.js');
3+
(document.head||document.documentElement).appendChild(s);}
4+
5+
{var s = document.createElement('script');
6+
s.src = chrome.extension.getURL('javascript.js');
7+
(document.head||document.documentElement).appendChild(s);}

manifest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@
55
"content_scripts": [
66
{
77
"matches": ["https://scratch.mit.edu/users*","https://scratch.mit.edu/studios*", "https://scratch.mit.edu/projects*"],
8-
"js": ["javascript.js"],
8+
"js": ["loader.js"],
99
"css": ["style.css"]
1010
}
1111
],
12+
"web_accessible_resources": ["smod.js", "javascript.js"],
1213
"browser_action": {
1314
"default_title": "ScratchFormat",
1415
"default_icon": "logo.png",

smod.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyleft Daniel C 2020
2+
// GNU General Public License v2.0
3+
4+
var smod = {
5+
dialog2: function(title, element) {
6+
openDialogue(element, {
7+
title: gettext(title),
8+
9+
open: function(e, t) {
10+
// Keeping for future reference
11+
},
12+
13+
close: function(e, t) {
14+
$(this).dialog("destroy");
15+
$(".ui-widget-overlay.ui-front").remove();
16+
},
17+
18+
show: {
19+
effect: "clip",
20+
duration: 250
21+
},
22+
23+
hide: {
24+
effect: "clip",
25+
duration: 250
26+
}
27+
});
28+
},
29+
30+
// This is bad, bad, bad. If anybody can find the native
31+
// way to create popups in Scratch 3.0 React.js, let me know.
32+
dialog3: function(title, text) {
33+
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.style.display = 'none';"><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>`;
34+
document.body.innerHTML += html;
35+
},
36+
37+
dialogText: function(title, text, version) {
38+
// A good way to check 2.0 vs 3.0 is
39+
// window["openDialogue"] == undefined
40+
if (version == 3) {
41+
this.dialog3(title, text);
42+
} else {
43+
var popupContent = document.createElement("div");
44+
popupContent.innerHTML = text;
45+
this.dialog2(title, popupContent);
46+
}
47+
}
48+
}

0 commit comments

Comments
 (0)