So I kinda-sorta made signatures...
-
I was bored...
// ==UserScript== // @name TDWTF signatures // @namespace TDWTF // @include http://what.thedailywtf.com/* // @version 1 // @grant none // ==/UserScript== var sig = 'Customize your signature here!'; document.addEventListener('mousedown', function (event) { // Trigger only on "Reply" button in submit-panel if(event.target.className.indexOf('create') > -1 && event.target.parentNode.className.indexOf('submit-panel') > -1) { var postInputArea = document.getElementById('wmd-input'); var postText = postInputArea.value; // Check if signature has already been appended if (postText.indexOf('tdwtf_signature_marker') == -1) { // Append the signature postInputArea.value = postText + '\n\r\n\r<tdwtf_signature_marker></tdwtf_signature_marker><hr>' + sig; } } });
I didn't submit it anywhere yet since I'm after some scrutinizing, and what better place than TDWTF to get it.
Also, someone who has access to IE should probably try it. I suspect it doesn't work, there should be a check if
addEventListener
is available and fall back toattachEvent
if not, but I can't test that properly so I didn't add it yet.
-
IE supports userscripts?
-
IE supports userscripts?
I don't know. I'd guess you could do it in some capacity. Maybe not userscripts per-se, but "run this piece of JS on this here site" is not some kind of incredible technology that only higher
beingsbrowsers can accomplish.… right?
-
I think you may be thinking too highly.
-
Ok, so I see one problem with this - "signatures" will get quoted. I think I could change the marker tags to denote start and end of signature and remove contents from DOM on quote button click. But I don't have the time now.
This would, of course, only work for those who have it active. But short of the plugin that's the best I can do.
-
I made my modifications but my javascript is rusty and I can't be bothered to look up the functions I most likely screwed up. Can anybody fix it:
// ==UserScript== // @name TDWTF signatures // @namespace TDWTF // @include http://what.thedailywtf.com/* // @version 1 // @grant none // ==/UserScript== document.addEventListener('mousedown', function (event) { // Trigger only on "Reply" button in submit-panel if(event.target.className.indexOf('create') > -1 && event.target.parentNode.className.indexOf('submit-panel') > -1) { var postInputArea = document.getElementById('wmd-input'); var postText = postInputArea.value; // Check if signature has already been appended if (postText.indexOf('Filed Under:') == -1) { var tagstring = ""; var tags = new array(); prompt("add Tags (split with | ):", tagstring); tags = tagstring.split('|'); tagstring = "Filed Under:"; for(i = 0; i<tags.size(); i++){ tagstring += ' [' + tags[i] + '](#tag) |'; } tagstring = substr(tagstring, -1); // Remove last | // Append the Tags postInputArea.value += '\n\r\n\r<hr />' + tagstring; } } });``` Because who needs signatures if you can just add tags to everything :smiley: Also: I want this as a plugin for Discourse (with an option in settings to turn it on and off) Also, please note my amazing reuse of tagstring. Thats totally well designed code, right? Filed Under: [did JS have foreach?](#tag) | [\[code\]\[/code\] do nothing T_T](#tag)
-
Filed Under: did JS have foreach?
Kind of:
for(i in arr) console.log(i + "th element of array is " + arr[i]);
do nothing T_T
They do. They break quotes, apparently. Also:
-
did JS have foreach?
First result on Google for
javascript foreach
:
Also, I suggest splitting on commas and shuffling the array before converting back to a string, for old time's sake.
Filed under: There's markdown for
<hr>
-
Will this implementation support Signature Guys? That's a much-missed feature.
-
This post is deleted!
-
This post is deleted!