Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d2007a0
Add @iconURL, @icon and @defaulticon
ponsfrilus Dec 12, 2018
2b8852c
Meta data improvements
ponsfrilus Dec 12, 2018
8b1e79f
Better script option with @conenct and @run-at
ponsfrilus Dec 12, 2018
3b3d2ad
Script rework
ponsfrilus Dec 12, 2018
8b4205d
Add link to every path of the unit
ponsfrilus Dec 12, 2018
bfe355c
Get userdata when logged-in
ponsfrilus Dec 12, 2018
42f7a4e
[chore] constistancy
ponsfrilus May 28, 2020
c93f6c5
[swag] console.log art
ponsfrilus May 28, 2020
a005dda
[fix] use same querystring to query search API
ponsfrilus May 28, 2020
b10751f
[fix] jQuery as $
ponsfrilus May 28, 2020
c89269c
[feat] better list view handling
ponsfrilus May 28, 2020
d263153
[feat] better support for opening admin data link
ponsfrilus May 28, 2020
adf5501
[ver] bump to 1.5.4
ponsfrilus May 28, 2020
00efb2f
[feat] ensure that works on both people and personnes subdomain
ponsfrilus May 28, 2020
eabe68b
[chore] meta block reorganisation
ponsfrilus May 28, 2020
42adeac
[doc] README and CONTRIBUTING
ponsfrilus May 28, 2020
aea1568
Merge branch 'feature/NewPeoplePage'
ponsfrilus May 28, 2020
fc91f2d
[fix] multiple scipers displayed in search.epfl.ch
ponsfrilus May 29, 2020
9e9616e
[doc] TOC + image + cleanup
ponsfrilus May 29, 2020
0f6cce0
Merge pull request #5 from ponsfrilus/doc/README
ponsfrilus May 29, 2020
b3f4af7
[fix] people page
ponsfrilus Sep 24, 2021
f470b87
[feature] Add "plan.epfl.ch" as iframe for each accred
ponsfrilus Oct 1, 2021
33c50cd
[fix] plan iframe position
ponsfrilus Oct 1, 2021
a8ff018
[feature] add ♀ / ♂ information in details page
ponsfrilus Oct 4, 2022
7eb1201
[feature] add pic thumbnail in list
ponsfrilus Oct 6, 2022
94e48f2
[fix] people.epfl.ch/signatures is now exlcuded
ponsfrilus Jan 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Contributing


♥ We love pull requests from everyone !


When contributing to this repository, please first discuss the change you wish
to make via issue, email, or any other method with the owners of this repository
before making a change.


## So all code changes happen through Pull Requests

Pull requests are the best way to propose changes to the codebase. We actively
welcome your pull requests:

1. Fork the repo and create your branch from `master`.
2. If you've added code that should be tested, add tests.
3. If you've added code that need documentation, update the documentation.
4. Be sure to test your modifications.
5. Write a [good commit message](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html).
6. Issue that pull request!


## Report bugs using Github's [issues](https://github.com/ponsfrilus/EPFL_People_UserScript/issues)

We use GitHub issues to track public bugs. Report a bug by [opening a new
issue](https://github.com/ponsfrilus/EPFL_People_UserScript/issues/new); it's
that easy!

## Feature reuqest using Github's [issues](https://github.com/ponsfrilus/EPFL_People_UserScript/issues)

We use GitHub issues to collect feature requests.
Add a feature reeqeuest by [opening a new
issue](https://github.com/ponsfrilus/EPFL_People_UserScript/issues/new); it's
that easy!
129 changes: 91 additions & 38 deletions EPFL_People.user.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
// ==UserScript==
// @name EPFL People
// @namespace none
// @version 1.9.0
// @description A script to improve browsing on people.epfl.ch
// @author EPFL-dojo
// @namespace EPFL-dojo
// @include https://people.epfl.ch/*
// @exclude https://people.epfl.ch/signatures/*
// @include https://personnes.epfl.ch/*
// @include https://search.epfl.ch/?filter=people&*
// @version 1.5.2
// @grant GM_addStyle
// @require https://code.jquery.com/jquery-3.5.1.min.js
// @author EPFL-dojo
// @downloadURL https://raw.githubusercontent.com/epfl-dojo/EPFL_People_UserScript/master/EPFL_People.user.js
// @downloadURL https://raw.githubusercontent.com/ponsfrilus/EPFL_People_UserScript/master/EPFL_People.user.js
// ==/UserScript==

// TODO: [ ] ask people to Tequila login if not
// TODO: [ ] get the groups
// TODO: [ ] get the mailinglist
// TODO: [ ] Add a modal with userscript info (https://epfl-si.github.io/elements/#/organisms/modal)

$(document).ready(async () => {

var TargetLink = $("a:contains('Administrative data')")

if (TargetLink.length)
window.location.href = TargetLink[0].href
console.log("%cCoded by EPFL-DOJO","color:#060;font-weight:bold;"),
console.log("%cPlease visit https://github.com/epfl-dojo/\nand checkout-out EPFL Userscripts here\nhttps://github.com/search?q=topic:epfl-userscript&type=Repositories\n\nFeel free to contribute (https://github.com/epfl-dojo/EPFL_People_UserScript) and add issues or feature request here\nhttps://github.com/epfl-dojo/EPFL_People_UserScript/issues","color:#08ff00;font-weight:bold;"),
console.log("%c ⊂(◉‿◉)つ","font-size:34px; line-height:1.4em;");

// Async function to get people's data from search-api
const getPeopleFromSearchAPI = async function (needle) {
var people = 'https://search-api.epfl.ch/api/ldap?q=' + needle
var searchURL = 'https://search-api.epfl.ch/api/ldap?q=' + encodeURIComponent(needle) + '&showall=0&hl=en&pageSize=all&siteSearch=people.epfl.ch'
var result = await $.ajax({
type: 'GET',
url: people,
url: searchURL,
async: true,
success: function ( data ) {
success: function (data) {
result = data
}
})
return result
}

const waitForEl = function (selector, callback) {
if (jQuery(selector).length) {
if ($(selector).length) {
callback()
} else {
setTimeout(function () {
Expand All @@ -47,41 +46,88 @@ $(document).ready(async () => {
}
}

const updateSearchResultsList = async (q) => {
// Query search-api for users
let users = await getPeopleFromSearchAPI(q)
console.log(users)
// In case we get some users
if (typeof users !== 'undefined') {
// Wait for the results element with class '.list-unstyled'
waitForEl('.list-unstyled', async () => {
// For each results
$('h3[class=h3] > a[class=result]').each(function(index, value) {
// Find the email (not all users have one, but for now it's the quickest way to get a unique identifier)
let usrEmail = $(this).parents('div[class=result]').find('a').last().html()
// Lookup in users which entry match this email
let usrObj = users.find(el => el.email === usrEmail)
// If nothing found, process the next element
if (typeof usrObj === 'undefined') {
return
}
// Have this user already have the span class sciperID (This can happen when using the search input)
let spanSciper = $(this).parents('h3').find('.sciperID')
if (spanSciper.length) {
// Found the span, replace the content
spanSciper.html('#' + usrObj.sciper)
} else {
// Span not found, insert it
$(this).after(' <span class="sciperID">#' + usrObj.sciper + ' </span>')
}

let userPictureUrl = `https://people.epfl.ch/private/common/photos/links/${usrObj.sciper}.jpg?ts=${Date.now()}`
let imageElement = `<img id="pic${usrObj.sciper}" class="userPic" alt="" src="${userPictureUrl}" style="width:100%;max-width:37px" />`
$(this).parents('h3').html((i,ori) => {
return `${imageElement} ${ori}`
})
})
})
} else {
// Insert the span class sciperID for the next search
waitForEl('.list-unstyled', async () => {
$('h3[class=h3] > a[class=result]').each(function(index, value) {
$(this).after(' <span class="sciperID"></span>')
})
})
}
}

// In case we are on https://search.epfl.ch/?filter=people&
if (document.URL.includes('https://search.epfl.ch')) {
console.log('Mode: list')
console.log('Waiting for results...')
// TODO: [x] wait for the list to be loaded
// TODO: [ ] handle pagination if more than 100 results

// Add the sciper number after the people's name
waitForEl('.list-unstyled', async () => {
console.log('...results found!')
const q = new URLSearchParams(window.location.search).get('q')
users = await getPeopleFromSearchAPI(q)
$('h3[class=h3] > a[class=result]').each(function (index, value) {
// console.log( index + ': ' + $( this ).attr( 'href' ) )
$(this).after(' #' + users[index].sciper)
})
const q = new URLSearchParams(window.location.search).get('q')
console.debug("Looking for", q)
updateSearchResultsList(q)
$('input[name=search]').on('input', (e) => {
updateSearchResultsList($('input[name=search]').val())
})
}

// In case we are on https://people.epfl.ch/*
// TODO: [ ] handle personnes.epfl.ch too
if (document.URL.includes('https://people.epfl.ch/')) {
// In case we are on https://people.epfl.ch/* or https://personnes.epfl.ch/*
if (document.URL.includes('https://people.epfl.ch/') || document.URL.includes('https://personnes.epfl.ch/')) {
console.log('Mode: details')
const users = await getPeopleFromSearchAPI(document.title)

let adminDataLink = $('a:contains("Administrative data"),a:contains("Données administratives")')
if (adminDataLink.length) {
adminDataLink[0].click()
}
// Comfort, open admindata by default
unsafeWindow.toggleVis('admin-data')

const name = $('h1#name').text()
const sex = ($('h1#name').attr('class').includes('pnf')) ? '♀' : '♂'
const users = await getPeopleFromSearchAPI(name)
if (users.length != 1) {
console.error(`⚠ Watchout: ${((users.length > 1) ? 'more than one user' : 'no user')} found!`)
}
const user = users[0]
// console.log(user)
// console.debug(user)
const sciper = user.sciper
const username = $('dt:contains("Username")').next('dd').html()

// Add sciper after name in title
$('#main > div.container > div.d-flex.flex-wrap.justify-content-between.align-items-baseline > h1').append(' #' + sciper)

// Comfort, open admindata by default
unsafeWindow.toggleVis('admin-data')
// Modify the main title adding sex and sciper
$('h1#name').text((i,ori) => {
return `${sex} ${ori} #${sciper}`
})

// Create a new div to host specific content of this script
$('.container:first > div > h1.mr-3').css('margin-bottom', '0px')
Expand All @@ -92,6 +138,13 @@ $(document).ready(async () => {
$('#EPFLPeopleUserScriptData').append('<div>username: ' + username + '</div>')
$('#EPFLPeopleUserScriptData').append('<div>email: ' + user.email + '</div>')
$('#EPFLPeopleUserScriptData').append('<div>unit: ' + user.accreds[0].path + '</div>')
for (accred in user.accreds) {
if (user.accreds[accred].officeList.length) {
for (office of user.accreds[accred].officeList) {
$(`#collapse-${accred}`).append(`<div><iframe id="userScript${accred}" height="350px" width="100%" src="https://plan.epfl.ch/iframe/?room==${office}&map_zoom=10"></iframe></div>`)
}
}
}
}

});
});
46 changes: 30 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
# EPFL People UserScript
A Greasemonkey/Tampermonkey script to improve browsing on people.epfl.ch
<!-- TOC titleSize:2 tabSpaces:3 depthFrom:1 depthTo:6 withLinks:1 updateOnSave:1 orderedList:0 skip:1 title:0 charForUnorderedList:* -->
* [Installation](#installation)
* [Features](#features)
* [On search.epfl.ch](#on-searchepflch)
* [On people.epfl.ch](#on-peopleepflch)
* [Example](#example)
<!-- /TOC -->

A user script to improve browsing on [search.epfl.ch] and [people.epfl.ch].

Improvement
-----------

### Improvement #1
Show the username and the sciper number in the title
## Installation

![Improvement #1](https://raw.githubusercontent.com/epfl-dojo/EPFL_People_UserScript/master/img/improvement-1.png)
![Improvement #1b](https://raw.githubusercontent.com/epfl-dojo/EPFL_People_UserScript/master/img/improvement-1b.png)
1. Install [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) (Firefox), [Tampermonkey](http://tampermonkey.net/) or [Violentmonkey](https://violentmonkey.github.io/);
1. Open the RAW content of [EPFL_People.user.js](https://raw.githubusercontent.com/ponsfrilus/EPFL_People_UserScript/master/EPFL_People.user.js);
1. Install and enable the script;
1. Enjoy new features while browsing [people.epfl.ch](http://people.epfl.ch), e.g. [169419](http://go.epfl.ch/nbo).

### Improvement #2
Show the mailing lists that the user belong to

![Improvement #3](https://raw.githubusercontent.com/epfl-dojo/EPFL_People_UserScript/master/img/improvement-2.png)
## Features

### On search.epfl.ch

* Add the sciper number next to the person's name

Installation
------------
### On people.epfl.ch

1. Install the Firefox add-on [Greasemonkey](https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/) or [Tampermonkey](http://tampermonkey.net/) for Chrome.
1. Open the RAW content of [EPFL_People.user.js](https://raw.githubusercontent.com/epfl-dojo/EPFL_People_UserScript/master/EPFL_People.user.js)
1. Install and enable the script
1. Browse to someone on [people.epfl.ch](http://people.epfl.ch), e.g. [169419](http://go.epfl.ch/nbo)
* Add the sciper number next to the person's name
* Auto-load the login page if not logged
* Toggle the admin data information
* Display information such as sciper, username, email and unit just below the person's name


## Example

![Kermit_profil](./img/Kermit_profil.png)


[search.epfl.ch]: https://search.epfl.ch
[people.epfl.ch]: https://people.epfl.ch
Binary file added img/Kermit_profil.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed img/improvement-1.png
Binary file not shown.
Binary file removed img/improvement-1b.png
Binary file not shown.
Binary file removed img/improvement-2.png
Binary file not shown.