Forums

RS-Linkify Thread is sticky

Quick find code: 261-262-33-65181208

AoDude

AoDude

Posts: 1,694 Mithril Posts by user Forum Profile RuneMetrics Profile
Playing around with the window.history.replaceState() function. No solid lead so far, it just seems to break all of the links on the page and send you back to "/community#"+$post_reference

Will let you know if I come up with anything good.
AO
Deputy-Owner :
The Nexus CC

03-Nov-2015 16:39:47 - Last edited on 03-Nov-2015 16:45:06 by AoDude

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
I have some code running replaceState in this current version, the trick is not to break the back button.

This is currently in my threadview.js

$('.thread-plate__last-post').on('click', function (e) {
var pUrl = $(this).parents('.thread-plate').find('.thread-plate__main-link').attr('href');
var current_url = window.location.href;
history.replaceState({},"",pUrl);
history.replaceState({},"",current_url);
});


You should notice when clicking last post the thread title re-colours just before the destination starts to load. This method keeps the back button working as it should too. Not sure if it's any help to you, but I thought I'd mention since it's currently running in Linkify.

03-Nov-2015 16:45:49 - Last edited on 03-Nov-2015 16:46:10 by Indecent Act

Indecent Act

Indecent Act

Posts: 7,456 Rune Posts by user Forum Profile RuneMetrics Profile
Okay success...

Using the history modifications I theorised about.

note session URL in image and visited threads.
HTTP://i.imgur.com/3sjBKFt.png

Then I logged out, and back in again. As expected it looked like this...
HTTP://i.imgur.com/uM15XWb.png

I ran my script and...
HTTP://i.imgur.com/nEDWVFM.png

Different session ID but all forum history has been updated to include the new ID.

It's almost 4:00am here so I'm going to leave it that for now. But I think this is the way to go.

If anyone finds a better method, I'll take it. But I think this is a pretty nice solution or at the very least has potential.

The script just needs a modification for the asynchronous "chrome.history.add" and chrome.history.deleteUrl. So they wait for each other. That's why the delete is commented out but I'll fix that and tidy it up when I'm awake. It works as it is though :)

function sIdFromURL(dUrl) {
"use strict";
if (dUrl === 0) {dUrl = document.URL; }
dUrl = dUrl.match(/^https?:\/\/(services|secure)\.runescape\.com[\w\W]+\/(c=[A-Z0-9\-\*]+?[?=\/])/i);
return dUrl ? dUrl[2] : null;
}
var fHistory = [];
chrome.history.search({text: 'http://services.runescape.com/m=forum/', maxResults: 500}, function(data) {
fHistory = data;
fHistory.forEach(function(page) {
//chrome.history.deleteUrl({"url" :p age.url}, function(data) {
page.url = page.url.replace(sIdFromURL(page.url), 'c =o V2Ueu6L210/').replace('sl=0/', '').replace('a=13/', '');
chrome.history.addUrl({"url" :p age.url});
//});
});
});


Edit: code requires history permission in manifest to work, published version of linkify currently does not have that.

03-Nov-2015 17:03:33 - Last edited on 03-Nov-2015 17:13:47 by Indecent Act

AoDude

AoDude

Posts: 1,694 Mithril Posts by user Forum Profile RuneMetrics Profile
Another thing that I noticed, not sure how many people use this feature, but:

http://puu.sh/l8ayQ/5ae9eed465.jpg

If you click the area at the end of the Thread Plate, it takes you right to the end of the thread. It seems the script needs to handle the reverse of seeing the end of the thread. (Marking the thread title as visited)

But I am excited about the script you have already. Very hopeful about that, and not a chrome extension dev, so I am not sure how hard it is to request the additional permissions.
AO
Deputy-Owner :
The Nexus CC

03-Nov-2015 19:27:03

AoDude

AoDude

Posts: 1,694 Mithril Posts by user Forum Profile RuneMetrics Profile
Morgan said :
Hey AoDude, why do you have my name in cyan? :O


That is my viewed thread color. Sorry not friends list color... I am not opposed to adding you though :P

But that is the indicator of the "visited" bug I was trying to highlight, it just happened that you replied last.
AO
Deputy-Owner :
The Nexus CC

03-Nov-2015 20:08:49

Quick find code: 261-262-33-65181208 Back to Top