Prolific Export

Forum export for surveys on Prolific

目前為 2016-11-11 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Prolific Export
// @namespace    https://kadauchi.com/
// @version      1.0.0
// @description  Forum export for surveys on Prolific
// @author       Kadauchi
// @icon         http://i.imgur.com/oGRQwPN.png
// @include      https://www.prolific.ac/studies*
// @grant        GM_log
// @grant        GM_setClipboard
// @require      https://code.jquery.com/jquery-3.1.1.min.js
// ==/UserScript==

for (var study of $('.study')) {
  var id = $(study).data('study-id');
  $(study).prepend('<button class="exporter" type="button" data-id="' + id + '">Forum Export</button>');
}

function export_study (id) {
  var $study = $('#' + id);

  var link = $study.find('a[href^="/studies/"]').prop('href');
  var title = $study.find('h3').text();

  var researcher = $study.find('li:eq(0)').text().split(':')[1];
  var reward     = $study.find('li:eq(1)').text().split(':')[1];
  var perhour    = $study.find('li:eq(2)').text().split(':')[1];
  var available  = $study.find('li:eq(3)').text().split(':')[1];
  var time       = $study.find('li:eq(4)').text().split(':')[1];
  var completion = $study.find('li:eq(5)').text().split(':')[1];

  var exportcode = '[table][tr][td]'+
      '[b][SIZE=5][COLOR=red]PROLIFIC STUDY[/COLOR][/SIZE][/b]\n' +
      '[b]Title:[/b] [URL=' + link + ']' + title + '[/URL]\n' +
      '[b]Hosted by : [/b] ' + researcher + '\n' +
      '[b]Reward : [/b][COLOR=green][b] ' + reward + '[/b][/COLOR]\n' +
      '[b]Avg. Reward Per Hour : [/b] ' + perhour + '\n' +
      '[b]Available Places : [/b] ' + available + '\n' +
      '[b]Maximum Allowed Time : [/b] ' + time + '\n' +
      '[b]Avg. Completion Time : [/b] ' + completion + '\n' +
      '[/td][/tr][/table]';

  GM_setClipboard(exportcode);
  alert('Forum export has been copied to your clipboard.');
}

$('.exporter').click(function() {
  export_study($(this).data('id'));
});