Skip to content

Instantly share code, notes, and snippets.

Embed
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)
}
);
@plbowers

This comment has been minimized.

Copy link

@plbowers plbowers commented May 17, 2017

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

@plbowers

This comment has been minimized.

Copy link

@plbowers plbowers commented May 17, 2017

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

This comment has been minimized.

Copy link

@plbowers plbowers commented May 17, 2017

Note I've replaced this line:

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

with this one:

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

@JCUIT

This comment has been minimized.

Copy link

@JCUIT JCUIT commented Mar 8, 2021

Thank you for this. Saved me a bunch of time with external yammer communities that are not connected to M365 groups so no sharepoint site to download from.

@Saturate

This comment has been minimized.

Copy link
Owner Author

@Saturate Saturate commented Mar 8, 2021

Thank you for this. Saved me a bunch of time with external yammer communities that are not connected to M365 groups so no sharepoint site to download from.

Glad you could use my old code :)

@dorjemrav

This comment has been minimized.

Copy link

@dorjemrav dorjemrav commented Jun 24, 2021

@Saturate - thanks for this. Cleaning up old Yammer groups now that we have TEAMS.
NOTE for other users
I found that removing the popup.close section of the code was required when downloading over a slow connection, as the popup windows were being closed prior to the download being complete.
Code I used was

[].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);
//I found the download tabs in Chrome closed when the download was complete
}
);

@Saturate

This comment has been minimized.

Copy link
Owner Author

@Saturate Saturate commented Jun 28, 2021

@dorjemrav happy that you could use some old code I forgot about :-) that's the awesome thing with open source. Have a nice summer!

@popeadam

This comment has been minimized.

Copy link

@popeadam popeadam commented Sep 9, 2021

I've a community with 700+ files; when I run this script, it times out after the first 50 or so. Can we easily add a short delay to the script so it opens a pop-up every 15 seconds?

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