Feedly Auto Scroll

Requirement:

Auto scroll feedly to the end of feed. Alert the user when end of page is reached using chrome notification

 

TLDR: The below script runs fine from chrome snippet in dev tools, but I wanted to run it in tampermonkey so that I don’t have to open dev tools all the time. (Another alternate is to runs js in bookmark bar, but I don’t enable that as well)

THe issue with running the same snippet as tampermonkey script is that that script doesn’t allow window object so scrolling etc. doesn’t work…

I tried all alternatives and other users’ scroll scripts and none works ….

Sticking to dev tools snippet for now…:(

WORKING CODE (for chrome dev tools SNIPPET):

if (Notification && Notification.permission !== "granted")
Notification.requestPermission();
else {
// alert('Desktop notifications not available in your browser. Try Chromium.');
}

//set timer
console.clear();

var myVar;
myVar = window.setInterval(function(){
if(document.getElementsByClassName("giant-mark-as-read").length > 0) {
clearTimeout(myVar);
if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification('Hi there...', {
icon: 'http://s3.feedly.com/img/feedly-512.png',
body: "All done.",
});
window.setTimeout(function(){notification.close()}, 5000)
window.setTimeout(function(){window.scrollTo(0,0);}, 500)
window.setTimeout(function(){document.getElementById("sortlySortImage").click()}, 500)

notification.onclick = function () {
window.focus(); this.cancel();notification.close();
};

}
}
console.clear();
window.scrollTo(0,document.body.scrollHeight); }, 1000);

if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');

}

 

NOT WORKING CODE for USERSCRIPT:

// @grant unsafeWindow
// @grant window.scrollTo
// @grant window
// @require http://code.jquery.com/jquery-2.0.3.min.js
// @copyright 2012+, You
// ==/UserScript==

GM_registerMenuCommand('Run this now', function() {
var speed = 15; // pixels per second
var duration = $(document).height() / (speed / 1000);

 

 

if (Notification && Notification.permission !== "granted")
Notification.requestPermission();
else {
alert('Desktop notifications not available in your browser. Try Chromium.');
}

//set timer
var myVar;
myVar = window.setInterval(function(){
if(document.getElementById("bigMarkAllAsReadButton")) clearTimeout(myVar);
window.scrollTo(0,document.body.scrollHeight); }, 1000);

//document.addEventListener('DOMContentLoaded', function () {
//});

function notifyMe() {
if (!Notification) {
alert('Desktop notifications not available in your browser. Try Chromium.');
return;
}

if (Notification.permission !== "granted")
Notification.requestPermission();
else {
var notification = new Notification('Notification title', {
icon: 'http://cdn.sstatic.net/stackexchange/img/logos/so/so-icon.png',
body: "Hey there! You've been notified!",
});

notification.onclick = function () {
window.open("http://stackoverflow.com/a/13328397/1269037");
};

}

}//https://jsfiddle.net/brilliancedisplay/9fe77anq/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s