// ==UserScript== // @name Quote in locked threads // @namespace https://bitcointalk.org // @version 0.1 // @description Save headache when quoting from locked threads // @author minifrij // @match https://bitcointalk.org/index.php?topic=* // @require https://code.jquery.com/jquery-3.4.1.slim.min.js // @grant none // ==/UserScript== function post2BB(input){ //This deletes all quotes in the post //I do this because I can't be arsed with them. //https://www.youtube.com/watch?v=Jne9t8sHpUc //Maybe it's something I'll fix later, if no one else has a go //Don't hold your breath though input = input.replace(/
';
$('div[id^="ignmsgbttns"]').prepend(quoteButton);
//Make said quote button do things
$('.td_headerandpost').on('click', '.fake-quote', function(){
let quoteBB = '';
let postArea = $(this).parents('.td_headerandpost');
//Get all the necessary stuff for building a quote
let quoteUser = postArea.prev().find('a[title^="View the profile of"]').text().trim();
let quoteLink = postArea.find('.subject a').attr('href').split('?')[1].trim();
let quoteDate = Math.round(new Date(postArea.find('.subject').next().text()).getTime()/1000);
//If the post has been edited, it'll run this
if(quoteDate.toString() == 'NaN'){
quoteDate = Math.round(new Date(postArea.find('.subject').next().find('span:first-child').text()).getTime()/1000);
}
//Build the quote
quoteBB += '[quote author=' + quoteUser + ' link=' + quoteLink + ' date=' + quoteDate + ']';
//Enjoy your meal.
quoteBB += post2BB(postArea.find('.post').html());
quoteBB += '[/quote]';
//Create a textarea, make it fill the post and put the quote inside
let quoteArea = '';
//Shove it in place of the post
postArea.find('.post').attr('style', 'position:relative;overflow:hidden;min-height:200px;');
postArea.find('.post').append(quoteArea);
});
})();