Go to profiles and trees from search results
目前為
// ==UserScript==
// @name MyHeritage Profile Helper
// @namespace nikku
// @license MIT
// @version 0.2
// @description Go to profiles and trees from search results
// @author nikku
// @match https://www.myheritage.am/research*
// @match https://www.myheritage.at/research*
// @match https://www.myheritage.cat/research*
// @match https://www.myheritage.cn/research*
// @match https://www.myheritage.co.il/research*
// @match https://www.myheritage.co.in/research*
// @match https://www.myheritage.co.kr/research*
// @match https://www.myheritage.com.br/research*
// @match https://www.myheritage.com.hr/research*
// @match https://www.myheritage.com.pt/research*
// @match https://www.myheritage.com.tr/research*
// @match https://www.myheritage.com.ua/research*
// @match https://www.myheritage.com/research*
// @match https://www.myheritage.cz/research*
// @match https://www.myheritage.de/research*
// @match https://www.myheritage.dk/research*
// @match https://www.myheritage.ee/research*
// @match https://www.myheritage.es/research*
// @match https://www.myheritage.fi/research*
// @match https://www.myheritage.fr/research*
// @match https://www.myheritage.gr/research*
// @match https://www.myheritage.hu/research*
// @match https://www.myheritage.it/research*
// @match https://www.myheritage.jp/research*
// @match https://www.myheritage.lt/research*
// @match https://www.myheritage.lv/research*
// @match https://www.myheritage.mk/research*
// @match https://www.myheritage.nl/research*
// @match https://www.myheritage.no/research*
// @match https://www.myheritage.pl/research*
// @match https://www.myheritage.ro/research*
// @match https://www.myheritage.rs/research*
// @match https://www.myheritage.se/research*
// @match https://www.myheritage.si/research*
// @match https://www.myheritage.sk/research*
// @match https://www.myheritage.tw/research*
// @icon https://www.google.com/s2/favicons?sz=64&domain=myheritage.com
// @grant none
// ==/UserScript==
function personId(item) {
return item[1] * 1000000 + parseInt(item[2]);
}
function createUrl(coll, item, name, link) {
switch (coll) {
case '1':
return '/person-' + personId(item) + ('_' + item[0]).repeat(2) + '/';
case '2':
return '/site-' + item + '/';
case '3':
return '/member-' + item + '_1/';
default:
return link;
}
}
function processData(data) {
data.forEach(function(rec) {
var coll = rec.record.collection.id.split('-')[1];
var item = rec.record.id.split('-')[2].split('_');
var name = rec.record.name;
var link = rec.user_info.link;
var newUrl = createUrl(coll, item, name, link);
if (link != newUrl) {
rec.user_info.link = newUrl;
rec.record.name = '✨ ' + rec.record.name;
if (coll == '1') {
var parts = rec.record.collection.name.split(',');
if (parts.length > 1) {
var tree = '<b><a onclick="event.stopPropagation();" href="/site-family-tree-' + item[0] + '/tree?rootIndivudalID=' + personId(item) + '&familyTreeID=' + item[1] + '">🌳 Tree</a></b>';
var website = '<span class="sub"><b><a onclick="event.stopPropagation();" href="/site-' + item[0] + '/">' + parts[0] + '</a></b></span>';
var admin = parts[1].replace(/(.*) (\S+ \S+)/, '$1 <b>$2</b>').replace('администрирует', 'адм.');
rec.record.collection.name = tree + website + ',' + admin;
}
}
}
if (coll == '40000') {
rec.record.collection.name = '🌀 ' + rec.record.collection.name;
}
if (coll == '40001') {
rec.record.collection.name = '🌱 ' + rec.record.collection.name;
}
});
}
(function(open) {
XMLHttpRequest.prototype.open = function() {
if (arguments[1].includes('search_in_historical_records')) {
this.addEventListener('load', function() {
var json = JSON.parse(this.responseText);
var res = json.data.search_query_upload.response.results;
if (res.data) {
processData(res.data);
Object.defineProperty(this, 'responseText', {writable: true});
this.responseText = JSON.stringify(json);
}
}, false);
}
open.apply(this, arguments);
};
})(XMLHttpRequest.prototype.open);