Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Download all files in a Yammer.com group. You have to enable popups. Only tested in chrome.
/*
# How to use:
1. Navigate to the files tab (https://www.yammer.com/COMPANY/groups/GROUP/uploaded_files)
2. Press F12.
3. Paste script in console and run it.
4. Enjoy downloading files!
# Not working?
1. Enable popups
2. Try too use chrome
*/
var time = 2000; // time before we close the popup again.
[].forEach.call(
document.querySelectorAll('.page-content .yj-tabular-data-name'),
function(el){
var fileid = el.pathname.split('/')[3];
var downloadPath = "https://www.yammer.com/api/v1/uploaded_files/"+fileid+"/download";
var popup = window.open(downloadPath);
// Close timout. You can skip this and just close all browser windows if you want.
setTimeout(function (argument) {
popup.close();
}, time)
}
);

Not working. Getting a bunch of URLs with "undefined".
Confirmed that I am using Chrome and that popups are enabled.

plbowers commented May 17, 2017 edited

This worked...

var time = 20000; // time before we close the popup again.

[].forEach.call(
  document.querySelectorAll('.page-content .yj-tabular-data-name'), 
  function(el){
 
    var fileid = el.href.match(/\/(\d+)$/)[1];
    var downloadPath = "https://www.yammer.com/api/v1/uploaded_files/"+fileid+"/download";
    var popup = window.open(downloadPath);
   
    // Close timout. You can skip this and just close all browser windows if you want.
    setTimeout(function (argument) {
        popup.close();
    }, time)

  }
);

plbowers commented May 17, 2017 edited

Note I've replaced this line:

var fileid = el.pathname.split('/')[3];

with this one:

var fileid = el.href.match(/\/(\d+)$/)[1];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment