Prolific Export

Forum export for surveys on Prolific

当前为 2016-11-11 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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'));
});