-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbeta.user.js
68 lines (54 loc) · 2.05 KB
/
beta.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// ==UserScript==
// @name Beta++
// @namespace https://github.com/cnkt/
// @description Eksi Beta Guzellestirici
// @include https://eksisozluk.com/*
// ==/UserScript==
var beta = beta || {};
beta.themeUrlTemplate = '//rawgit.com/cnkt/eksi-beta/master/ui/themes/{{theme-uid}}';
beta.themesListUrl = '//rawgit.com/cnkt/eksi-beta/master/themes.json';
beta.themeList = {"themes": []};
beta.downloadThemeList = function() {
$.ajax({
url: beta.themesListUrl,
async: false,
success: function(data) {
beta.themeList = data;
}
})
};
beta.isBetaThemesPage = function() {
var url = document.URL;
if (url.indexOf('3566713') > -1) {
return true;
}
return false;
};
beta.injectTheme = function(themeUid) {
var cacheBuster = new Date().getTime();
$('head').append('<link rel="stylesheet" href="' + beta.themeUrlTemplate.replace('{{theme-uid}}', themeUid) + '/theme.css?' + cacheBuster + '" type="text/css" />');
}
$(function() {
$('#top-navigation >ul').prepend('<li><a href="https://eksisozluk.com/beta-temalari--3566713" id="runBeta">Beta++</a></li>');
if (GM_getValue('betaTheme') === 'undefined') {
GM_setValue('betaTheme', 'teddybearogullari');
}
beta.injectTheme(GM_getValue('betaTheme'));
if (beta.isBetaThemesPage()) {
var entryDiv = $('#li30471207 .content');
var themeListHtml = '<ul id="betaThemeList">';
$('body').on('click', '#betaThemeList', function(e) {
e.preventDefault();
$element = $(e.target);
var themeUid = $element.attr('data-theme-uid');
beta.injectTheme(themeUid);
GM_setValue('betaTheme', themeUid);
});
beta.downloadThemeList();
$.each(beta.themeList.themes, function(index, item) {
themeListHtml += '<li><a href="#" data-theme-uid="' + item.uid + '">' + item.title + '</a></li>';
});
themeListHtml += '</ul>'
entryDiv.append(themeListHtml);
}
});