Skip to content

Instantly share code, notes, and snippets.

View gosoccerboy5's full-sized avatar
💻
Check out my new games, Entry Breach and Plane Battle!

gosoccerboy5

💻
Check out my new games, Entry Breach and Plane Battle!
View GitHub Profile
@gosoccerboy5
gosoccerboy5 / quote-with-credit.js
Last active June 19, 2021 03:16
Code to change the quote function on the forums
javascript: window.copy_paste = function(id) {
let substr = id.toString().substring(1);
let username = document.querySelector("#" + id).querySelector(".username").innerText;
fetch("/discuss/post/" + substr + "/source/")
.then(res => res.text())
.then(function(data) {
paste("[quote=" + username + "][small][i]([url=https://scratch.mit.edu/discuss/post/" + substr + "][color=grey]Original post[/color][/url])[/i][/small]\n" + data + " [/quote]");
});
};
void(0);
function stripBBCode(txt) {
return txt.replaceAll(/\[((?!\[).)*?\]/g, "");
}
alert(stripBBCode(prompt("What BBCode?")));
/*
View here {
https://regex101.com/r/5RtRdv/1
}
Context {
@gosoccerboy5
gosoccerboy5 / blockly-minify.js
Last active June 6, 2021 15:28
Minify XML generated by Blockly.
(function minifyXML(source) {
source.value = source.value.replaceAll(/\n */g, "");
source.select();
})(document.querySelector("#content_xml"));
/*
Blockly {
https://scratch.mit.edu/discuss/topic/491165/
}
Context {
https://scratch.mit.edu/discuss/post/4990156/
@gosoccerboy5
gosoccerboy5 / expand-search-bar.js
Last active June 29, 2021 16:54
Make the search bar expandable on Scratch pages.
// Inspiration from <https://gist.github.com/CST1229/1063d77b16593e036764b75e56788f8e>
// This will make the Scratch search bar expandable when clicked, like the Scratch Wiki (https://en.scratch-wiki.info)
// This is free and open source, but please use credit if you take all of the code (small snippets are free).
// Use at your own risk! If you do not trust the code, DO NOT USE IT!
const style = document.createElement("style");
style.innerText = ".__hidden { display: none !important; }"; // Will hide nav items
document.body.append(style);
let setup = function(input, nav) {
@gosoccerboy5
gosoccerboy5 / block-elements.js
Last active June 6, 2021 01:25
Block elements on a webpage.
javascript: var evtHandler = function (e) {
e.preventDefault();
e.stopPropagation();
if (confirm("Do you want to delete this element?")) {
e.target.remove();
}
document.body.removeEventListener("click", evtHandler);
};
document.body.addEventListener("click", evtHandler);
// To use: run the code, click an element to delete it.
@gosoccerboy5
gosoccerboy5 / _replace-indentation.dart
Last active June 23, 2021 01:00
A recreation of replace-indentation.html on my formatting-help repository.
import "dart:html";
final input = querySelector("#input") as TextAreaElement;
final output = querySelector("#output") as TextAreaElement;
final button = querySelector("#format") as ButtonElement;
final number = querySelector("#spaces") as InputElement;
final oldNumber = querySelector("#oldspaces") as InputElement;
// Setup the variables
void main() {
@gosoccerboy5
gosoccerboy5 / curly-brackets.dart
Last active June 24, 2021 16:08
A recreation of curly-brackets.html on my formatting-help repository.
import "dart:html";
final input = querySelector("#input") as TextAreaElement;
final output = querySelector("#output") as TextAreaElement;
final btn = querySelector("#button") as ButtonElement;
final radio = querySelector("#sameline") as RadioButtonInputElement;
// Setup elements
void main() {
btn.addEventListener("click", (Event event) {
@gosoccerboy5
gosoccerboy5 / _tabs-to-spaces.dart
Last active August 27, 2021 20:41
A recreation of tabs-to-spaces.html on my formatting-help repository.
import "dart:html";
final input = querySelector("#input") as TextAreaElement;
final output = querySelector("#output") as TextAreaElement;
final radio = querySelector("#tabs2spaces") as RadioButtonInputElement;
final button = querySelector("#button") as ButtonElement;
final spacesPerTabs = querySelector("#spacesPerTabs") as InputElement;
// Setup elements
void main() {
@gosoccerboy5
gosoccerboy5 / _trim-whitespace.dart
Last active July 19, 2021 15:18
A recreation of trim-whitespace.html on my formatting-help repository.
import "dart:html";
final input = querySelector("#input") as TextAreaElement;
final target = querySelector("#output") as TextAreaElement;
final number = querySelector("#amount") as InputElement;
final trigger = querySelector("#trigger") as ButtonElement;
// Setup elements
void main() {
input.addEventListener("input", (Event event) {
@gosoccerboy5
gosoccerboy5 / numbersasfunctions.dart
Last active July 25, 2021 22:06
Using numbers - as functions
const pi = 3.1415;
extension NumbersAsFunctions on num {
num call(num other) => this * other;
}
void main() {
print(2(pi)); // 6.283
}