Extended Scripts for Tildes Alpha
So, after a rather clunky script to open comment's link in a new tab with the left click, I got inspired by the idea of @kalebo and wrote also a script to quickly jump to new comments in a topic.
I thought about writing a dedicated script but felt like it was going to become overly complicated for a user to import different script.
- The script itself is here: https://gist.github.com/theCrius/04dc86bea0ed0f1cbec7e57f1aaff9aa
- I wrote it with tampermonkey in mind: http://tampermonkey.net/
Please read further as tampermonkey has issues with custom styles. - And here is a simple tutorial on how to load script in tampermonkey: https://imgur.com/a/pY51wn2
These script are all meant to give the community some QoL while lightening the pressure on @deimos so he can work without too much stress from all the requests. As soon as the feature are implemented you should get rid of those script that in some parts felt like bad hacks to me that I was writing it.
I know the button to scroll to new messages is in a quite bad position (top center of your browser page) but I couldn't bear to deal with tampermonkey issue and its GM_AddStyle meta not working properly so I had to use the basic CSS provided by spectre already loaded in tildes.net.
If someone knows how to figure out that goddamn meta, let me know.
========= UPDATE ============
Edit: So apparently tampermonkey has issues with styles that are not yet fixed and firefox has some issue in general with script that inject stuff in the page (understandably).
For tampermonkey the solution is simple. Use violentmonkey instead. you can just copy the script and it will work.
For Firefox it's a little more dirty unfortunately but I cannot find other solutions. You need to open the internal URL about:config
. Then search security.csp.enable
and double click to disable it. After this the script will work.
Firefox has a very strict policy and the only real solution would be to write an extension and I don't think it's worth the effort in the current state of development.
For full description of what that policy does, check the official doc from mozilla: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP#Threats
Modern browser extensions are just javascript. No need for things like tampermonkey or even jQuery anymore. This could be rewritten in a few lines of vanilla js, packaged, and be on the Chrome and Firefox extension markets in a couple hours.
The new tab functionality could be rewritten without the jQuery overhead. Something like this would do it:
Scrolling to new comments would take a bit more work, but there's really no need for jQuery these days. Those five lines do it.
Yep I agree, it's just that tildes is written on top of jQuery and intercooler and I wanted to try my hand at some jQuery that I don't use since... Forever?
I thought about an extension but in alpha with the source code going to be released soon it wasn't worth it to go through the Chrome and Firefox market imho.
Edit: I also decided to use jquery to allow non-tech to understand the gist of it and decide to trust the script or not. Most of the time JS have really convoluted way to do simple things (see when you need to remove an element from the DOM) while jquery simply does $('#this-guys').delete() that everyone really can undersand what it does.
I thought about this (and honestly your current project is quite interesting from the technical standpoint already) but I just don't know how it will sit well with @Deimos intention of having this website being the "front face" of the platform. At least if I remember correctly how it was worded in the announcement or one of the documents.
I was even feeling kind of guilty in thinking about building a mobile app as soon as the APIs comes out just because I always wanted to try my hand at native mobile apps but hey, I say that until we respect the license that Deimos choose, every initiative is a good initiative :)
This is a lifesaver! I have been monitoring the comments sections on the site to ensure there is no abusive behavior and with some of the larger ones it was getting incredibly painful to identify the new comment locations. This has made my life a lot easier... so thank you.
Hey, thanks @cfabbro, you're too kind as usual :)
Please note that you can get rid of the script that opens comments link in new tab by default as it's included in this one.
Also this works on any fork of grease monkey as far as I've seen. There is a stricter security restriction on Firefox that prevent it from running, I'll try and identify and fix it by the end of today.
==== UPDATE ====
So apparently tampermonkey has issues with styles that are not yet fixed and firefox has some issue in general with script that inject stuff in the page (understandably).
For tampermonkey the solution is simple. Use ViolentMonkey instead. you can just copy the script and it will work. They're both forks of GreaseMonkey and follow the same standards.
For Firefox it's a little more dirty unfortunately but I cannot find other solutions. You need to open the internal URL
about:config
. Then searchsecurity.csp.enable
and double click to disable it. After this the script will work.For full description of what that policy does, check the official doc from mozilla: https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP#Threats
Firefox has a very strict policy and the only real solution would be to write an extension and I don't think it's worth the effort in the current state of development.
I also just updated the script to put the button in a more natural position (on the right side where there is plenty of free space) and thanks to ViolentMonkey supporting add styles properly I managed to make it not create an invisible overlay on the line it appears that make impossible clicking on elements on the same Y-axis of the button in the current version.
Bumping this post so people are aware of this script... it's been a lifesaver for me. ;)
This looks like it would be an improvement over my snippet, but the button to jump to new is not showing up with Violentmonkey (I'm not a fan of tampermonkey's licence) on Firefox. In short CSP strikes again. I'm assuming it has something to do with this issue. I'll have to see if there is a work around when I have more time.
Hey I didn't check violentMonkey and choose tamperMonkey just because someone else suggested it. If you think you can port it for ViolentMonkey just share the code!
It's always JS I mean, it's probably different only in the metadata of the header?
Edit: It could be something with specific on firefox. I tested only on chrome, I'll give it a look tomorrow :)
Yep, just loaded violentmonkey on chrome and it works. Definitely something with firefox. Weird :-/