New script: IP Board Post Numbers

This commit is contained in:
Makaze 2017-01-18 11:55:17 -05:00
parent be46403ec2
commit 3220d634d5
2 changed files with 69 additions and 0 deletions

View File

@ -0,0 +1,64 @@
// ==UserScript==
// @name IP.Board - Post Numbers
// @namespace Makaze
// @description Replaces the "Share post" icon with the post number.
// @include *
// @grant none
// @version 1.0.0
// ==/UserScript==
var MakazeScriptStyles,
styleElem;
function createElement(type, callback) {
var element = document.createElement(type);
callback(element);
return element;
}
function runInJQuery(code) {
if (typeof(jQuery) == "undefined") {
document.body.appendChild(createElement('script', function(jQ) {
jQ.type = 'text/javascript';
jQ.src = 'https://code.jquery.com/jquery-2.1.3.min.js';
jQ.onload = function() {
document.body.appendChild(createElement('script', function(content) {
content.appendChild(document.createTextNode('jQuery.noConflict();' + code));
}));
};
}));
} else {
document.body.appendChild(createElement('script', function(content) {
content.appendChild(document.createTextNode(code));
}));
}
}
function main() {
var page = 1;
setInterval(function() {
jQuery('.cPost').each(function(event) {
var $self = jQuery(this),
shareLink = $self.find('[data-role="shareComment"]'),
postNumber;
if (jQuery('.ipsPagination_active').length) {
page = parseInt(jQuery('.ipsPagination_active > a').data('page'));
}
postNumber = ((page - 1) * 25) + (parseInt(jQuery('.cPost').index($self)) + 1);
if (shareLink.text().indexOf('#') < 0) {
shareLink.text('#' + postNumber);
}
});
}, 500);
}
if (document.body.className.indexOf('ipsApp') > -1) {
runInJQuery(createElement.toString() + main.toString() + ';main();');
}

View File

@ -19,6 +19,7 @@ A collection of my client-side userscripts.
* [`IP.Board_Navigation_Shortcuts.user.js`](#ipboard_navigation_shortcutsuserjs-more)
* [`IP.Board_Plaintext_BBCode.user.js`](#ipboard_plaintext_bbcodeuserjs-more)
* [`IP.Board_Post_Loss_Prevention.user.js`](#ipboard_post_loss_preventionuserjs)
* [`IP.Board_Post_Numbers.user.js`](#ipboard_post_numbersuserjs)
* [`IP.Board_Post_Style.user.js`](#ipboard_post_styleuserjs-more)
* [`IP.Board_Prevent_Video_Preload.user.js`](#ipboard_prevent_video_preloaduserjs)
* [`IP.Board_Quote_Search_Results.user.js`](#ipboard_quote_search_resultsuserjs)
@ -122,6 +123,10 @@ A collection of my client-side userscripts.
**Name**: IP.Board Post Loss Prevention
**Description**: Force the browser to ask you before leaving a page with an unfinished post.
#### `IP.Board_Post_Loss_Prevention.user.js`
**Name**: IP.Board - Post Numbers
**Description**: Replaces the "Share post" icon with the post number.
#### `IP.Board_Post_Style.user.js` [More](../../wiki/IP.Board:-Post-Style "Wiki")
**Name**: IP.Board - Post Style
**Description**: Adds options to apply a predefined style to posts in a variety of ways.