-
Notifications
You must be signed in to change notification settings - Fork 131
New Extension: Addressbar Updater #1656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
8d82d1e
cd9b7a7
be57579
50c2e2c
c4c8d77
7cf49b8
3a5d8f8
41f2a42
5b7a6bb
68817de
482dae5
beafe27
eec048b
db4e23c
927c6fe
d4a1074
23d6cd3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAG00lEQVR4nO2aW0xb9x3HP8f3CxdzCRQaDE0wkMTYTkPUtA9Z1ipZ0kbRnlapD9mmTVpVKQ9b14dt1bSHTYu2VtOqPUxqm66pEvUylIRNybamLCkkUMKSEGjBFwKBEK4GYwffDvbZAwmpFXANMxxW/Hk7///3f/T9ff3/+/zPRbg77ZNYxyjkNiA3mQDkNiA3mQDkNiA3mQDkNiA3mQDkNiA36z4AVSqi4MwMVz5rYXDwFncDgZX29D9jMBh51FxGXd0uck2mpFrhq+4F3K4eTrx7jEDAn1aTq4Fer+f5Fw5Ta9++qCbpEggE/Bx/583/y+IBQqEQJ947hnd8bFFN0iXQdKGR4MxM2o0tl+otW7HZdzzUHgmHaPzkn8RiMfbtP8j1q+3c6r8JgBgVOf/xP3j+hcMLnjNpALf6+9JgO33sf/YQ5vKKBfuGh4cIh0Ps3vM0WVnG+QAABm4tXkfSAPz+6eU5XSFOHD9GVc0WBISE9nA4xI3rV5Ek+ODkcdzOnoT+aZ9v0XMmDUBaY49KJsbHmEiyngHaWi8/1Jasjsw+IBVRxWOb+N4PfrTSXtLOXz88SdeNjqSalAJQqpR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cgOAY+jPfRhDv3gtFC7FIwjjJWELo0CkkteFBmyQxPjaKTqcnJzeXUDBIIODHlJ+PRj03q2ZnZ5n0TmAwGsnKyiYQ8BMKBincUIRCMfdbRSMRfL4pcnJz0en0+Hw+xGiEDUXFiFGRqSnv/Pj3/vIW16+2o9Pp+c3v/rBgjUu+DEqGIiJ7Xkfb/HOEkPeh4uPZZiLf+H1C8QCCIFBU/Mj8sd5gQG9I1KhUqgRNdnYO2dk5CRqNVpugMX3pzY9ao07oS4Vl7QRjJU8SOnQKdeebKIdbEcKTSPoiYmV7iFq/D0rdck4rC8veCktaE9G6V9LpRRbW/d1gJgC5DchNJgC5DchNJoCknfd2X/H4GntLmiLSPd/361iIpAEUFRcBMDJ8h2gkkky65ojHYtweGgRIujtMuhHaXFlFZ8d1QsEg77z1Z7514LmHtqZrkZlgkAuNH89/GlNpqVpUm/RmKBaL8cfXfsvQ0O30u1wl8vMLeOVnv0Sj1S7Yn3QJKJVKfvjiEbZZa1fE3EqzqdLCi0d+vGjxkMJncvcZGR5mcKAff2BtfTazEEZjFmXmCkpLH0UQhKTalAP4upLZB8htQG4yAchtQG4yAchtQG4yAchtQG4yAchtQG4UQOov0r6G/BeInHmZq8umBgAAAABJRU5ErkJggg== |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| //* TITLE Addressbar Updater **// | ||
| //* VERSION 1.0.1 **// | ||
| //* DESCRIPTION Keeps the url in its place **// | ||
| //* DEVELOPER srsutherland **// | ||
| //* DETAILS Sets the url to the current post on your dashboard (to keep your place during tab crashes and refreshes). **// | ||
| //* FRAME false **// | ||
| //* BETA false **// | ||
| //* SLOW false **// | ||
|
|
||
| XKit.extensions.addressbar = new Object({ | ||
|
|
||
| running: false, | ||
| interval: 0, | ||
| initialScroll: history.scrollRestoration, | ||
|
|
||
| preferences: { | ||
| "focus_only": { | ||
| text: "Only run the extension when the page has focus", | ||
| default: true, | ||
| value: true | ||
| }, | ||
| }, | ||
|
|
||
| run: function() { | ||
| this.running = true; //there's some confusion over whether this gets set to true on immediate return | ||
|
|
||
| const Xwhere = XKit.interface.where(); | ||
| if (Xwhere.dashboard !== true || Xwhere.endless !== true) { | ||
| return; //only useful on endless dashboard | ||
| } | ||
|
|
||
| this.interval = setInterval(this.update_address, 500); | ||
|
|
||
| history.scrollRestoration = "manual"; //prevent page from jumping to bottom on refresh | ||
AprilSylph marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| }, | ||
|
|
||
| find_top: function() { | ||
| var offset = 200; //place slightly below navbar to ignore reblog controls | ||
| var scrollPos = $(window).scrollTop() + offset; | ||
| var minDist = Number.MAX_SAFE_INTEGER; | ||
| var id = null; //check later and do nothing to history if no post qualifies | ||
|
|
||
| $("[data-id]").each(function() { | ||
| var dist = scrollPos - $(this).offset().top; | ||
| //if it equals exactly 200 that's a bogus value | ||
| if (dist > 0 && dist !== offset && dist < minDist) { | ||
| minDist = dist; | ||
| id = $(this).attr('data-id'); | ||
| } | ||
| }); | ||
| return id; | ||
| }, | ||
|
|
||
| replace_address: function(postid) { | ||
| postid = BigInt(postid); | ||
| window.history.replaceState( | ||
| { id: postid }, | ||
| 'Tumblr - ' + postid, //title param is ignored currently | ||
| '?max_post_id=' + (postid + BigInt(1)) //has to be the id immediately after | ||
| ); | ||
| }, | ||
|
|
||
| update_address: function() { | ||
| if (!XKit.extensions.addressbar.focus_only || document.hasFocus()) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| //do nothing if you're not in focus | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment should be removed too |
||
| var id = XKit.extensions.addressbar.find_top(); | ||
| if (id !== null && id > 1) { | ||
| XKit.extensions.addressbar.replace_address(id); | ||
| } | ||
| return id; //unused/debug | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. always remove debug lines |
||
| } | ||
| }, | ||
|
|
||
| destroy: function() { | ||
| this.running = false; | ||
| clearInterval(this.interval); | ||
| history.scrollRestoration = this.initialScroll; | ||
| } | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.