Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name opchan backlinks
- // @namespace http://*operatorchan.org/*/res/*
- // @description opchan backlinks
- // @require http://code.jquery.com/jquery-2.1.1.min.js
- // @version 1
- // @grant none
- // ==/UserScript==
- //partly based on the "4chan pretty thread" userscript
- //root-post
- var firsPostId = $('.reflink:first').text().replace(/[^0-9]+/g, '');
- $('<div class="repliesDiv" id="replies-'+firsPostId+'" ><span class="RplyMsg"> Replies to this post: </span></div>').insertAfter('.reflink:first');
- $('#replies-'+firsPostId).css('display','none');
- // wrap replies
- $(".reply").each
- (
- function()
- {
- var id = $(this).attr("id").replace("reply","");
- var reply = $(this).parents().get(2);
- $(reply).wrap('<div id="parent-'+id+'"></div>');
- $("a[name='"+id+"']").prependTo("#parent-"+id);
- $('<div class="repliesDiv" id="replies-'+id+'" ><span class="RplyMsg"> Replies to this post: </span></div>').insertAfter($(this).find('.reflink'));
- $('#replies-'+id).css('display','none');
- }
- );
- //add param: the ID from the post that quoted
- $('.reply').each
- (
- function ()
- {
- var currentPost = $(this);
- var id = currentPost.attr('id').replace('reply', '');
- // alert(id);
- currentPost.find('a').each
- (
- function ()
- {
- if ($(this).attr('class') != null)
- if ($(this).attr('class').match(/^ref.+/))
- {
- var ctemp = $(this).attr('class');
- $(this).attr('class', ctemp+'|'+id);
- }
- }
- );
- }
- );
- //add quotelinks
- $("a").each
- (
- function()
- {
- if ( $(this).attr('class') != null )
- if ( $(this).attr('class').match(/^ref.+/) )
- {
- var myarr = $(this).attr('class').split("|");
- var parentid = myarr[3];
- $('<a class="ref|'+ myarr[1]+'|'+ myarr[2]+'|'+ myarr[4] +'" href="#'+myarr[4]+'">>>'+myarr[4]+' </a>;').appendTo("#replies-"+parentid);
- $('#replies-'+parentid).css('display','inline');
- }
- }
- );
- $("<style type='text/css'> .repliesDiv{; margin: 3px 5px 0px 3px;} .RplyMsg{font-style: italic;}</style>").appendTo("head");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement