d2jsp
Log InRegister
d2jsp Forums > d2jsp > Ladder Slasher > Question Regarding Grease Monkey Script
Add Reply New Topic New Poll
Member
Posts: 6,991
Joined: Apr 16 2019
Gold: 50.00
Mar 12 2020 07:24pm
I learned about a script that allows you to see item ID's but I can't seem to get it to work;

Using Chrome

Put this in for the script;

Code

// ==UserScript==
// @name Show Item IDs
// @namespace http://tampermonkey.net/
// @version 0.1
// @author Dante@JSP
// @match http://forums.d2jsp.org/user.php?c=&i=&p=
// ==/UserScript==

/* jshint ignore:start */
(function() {
var elements = Array.apply(null, document.querySelectorAll('dd.ce'))
// Get all elements except the first because we don't want that
.slice(1)
// Convert nodeList to native arrays and remove the text elements
.map(a => Array.apply(null, a.childNodes).filter(b => b.nodeType !== 3))
.reduce( (prev, curr) => prev.concat(curr), [])
// Filter empty elements that are at the end
.filter(a => a.className !== 'c');

elements
.reduce( (prev, curr) => {
// Previous node was a comment and current node is an item
if (prev.nodeType === 8 && curr.nodeType === 1) {
const id = prev.data.match(/\d{1,99}/)[0];
const core = document.querySelectorAll('.ftbt')[0].childNodes[1].childNodes[2].childNodes[1].innerHTML === 'Original' ? 0 : 1;
const url = http://ladderslasher.d2jsp.org/itemHistory.php?i=${id}&c=${core}

curr.innerHTML += <br/><a href=${url}>ID: ${id}</a>;
curr.style.height = '100%'
}

// Always return the node for the next iteration
return curr;
}, {nodeType: null})


var maxHeight = elements
.reduce( (prev, curr) => prev > curr.offsetHeight || !curr.offsetHeight ? prev : curr.offsetHeight, 0);

elements
.forEach(ell => {ell.nodeType === 1 && (ell.style.height = ${maxHeight}px)});

})()


But it never says a script is running and I can't seem to find anything related to enabled it or using it on the site.

Anyone else use this?

Thanks!
Member
Posts: 13,935
Joined: Jan 4 2004
Gold: 130,215.17
Mar 12 2020 07:49pm
you dont need a script. right click on the item and hit INSPECT. right above it will be a number <!-- 1234567 --> that is your ID
Member
Posts: 91,260
Joined: May 14 2008
Gold: 45,236.55
Mar 12 2020 07:52pm
you have to use tampermonkey addon, mine works for firefox
Member
Posts: 6,991
Joined: Apr 16 2019
Gold: 50.00
Mar 12 2020 07:53pm
Quote (k.iMpacT @ Mar 12 2020 09:49pm)
you dont need a script. right click on the item and hit INSPECT. right above it will be a number <!-- 1234567 --> that is your ID


Yeah, I know I can do it like that but if this script works where I do nothing, why not remove a step.

Quote (Pick @ Mar 12 2020 09:52pm)
you have to use tampermonkey addon, mine works for firefox


I do have Tampermonkey installed and the script enabled :(
Member
Posts: 23,911
Joined: Aug 21 2007
Gold: 2,494.65
Trader: Trusted
Mar 13 2020 12:40am
There are asterisk missing in the URL

http*://forums.d2jsp.org/user.php?c=*&i=*&p=*

This post was edited by Meridius on Mar 13 2020 12:41am
Member
Posts: 73,189
Joined: Jun 12 2007
Gold: 2.63
Trader: Trusted
Mar 13 2020 03:56am
Like Meridius said the *'s are missing.. Copy this code instead

Code
// ==UserScript==
// @name Show Item IDs
// @namespace http://tampermonkey.net/
// @version 0.1
// @author Dante@JSP
// @match http*://forums.d2jsp.org/user.php?c=*&i=*&p=*
// ==/UserScript==

/* jshint ignore:start */
(function() {
var elements = Array.apply(null, document.querySelectorAll('dd.ce'))
// Get all elements except the first because we don't want that
.slice(1)
// Convert nodeList to native arrays and remove the text elements
.map(a => Array.apply(null, a.childNodes).filter(b => b.nodeType !== 3))
.reduce( (prev, curr) => prev.concat(curr), [])
// Filter empty elements that are at the end
.filter(a => a.className !== 'c');

elements
.reduce( (prev, curr) => {
// Previous node was a comment and current node is an item
if (prev.nodeType === 8 && curr.nodeType === 1) {
const id = prev.data.match(/\d{1,99}/)[0];
const core = document.querySelectorAll('.ftbt')[0].childNodes[1].childNodes[2].childNodes[1].innerHTML === 'Original' ? 0 : 1;
const url = `http://ladderslasher.d2jsp.org/itemHistory.php?i=${id}&c=${core}`

curr.innerHTML += `<br/><a href=${url}>ID: ${id}</a>`;
curr.style.height = '100%'
}

// Always return the node for the next iteration
return curr;
}, {nodeType: null})


var maxHeight = elements
.reduce( (prev, curr) => prev > curr.offsetHeight || !curr.offsetHeight ? prev : curr.offsetHeight, 0);

elements
.forEach(ell => {ell.nodeType === 1 && (ell.style.height = `${maxHeight}px`)});

})()
Go Back To Ladder Slasher Topic List
Add Reply New Topic New Poll