-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmetacriticall.user.js
More file actions
161 lines (136 loc) · 7.36 KB
/
Copy pathmetacriticall.user.js
File metadata and controls
161 lines (136 loc) · 7.36 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// ==UserScript==
// @name MetaCriticAll
// @namespace http://stackoverflow.com/users/982924/rasg
// @author RASG
// @version 2016.12.30.1011
// @description Metacritic ratings everywhere. See the supported sites in the @include section of the script.
// @icon https://www.google.com/s2/favicons?domain=metacritic.com
// @require http://code.jquery.com/jquery.min.js
// @resource metacritic.global.css https://raw.githubusercontent.com/yodog/userscripts/master/res/metacritic.global.css
// @resource metacritic.base.css https://raw.githubusercontent.com/yodog/userscripts/master/res/metacritic.base.css
// @resource metacritic.css https://raw.githubusercontent.com/yodog/userscripts/master/res/metacritic.css
// @grant GM_addStyle
// @grant GM_getResourceText
// @grant GM_log
// @grant GM_xmlhttpRequest
// @include http*://*.getgamesgo.com/*
// @include http*://*.greenmangaming.com/*/games/*
// @include http*://*.nuuvem.com.br/produto*
// @include http*://*steamcommunity.com/id/*/wishlist
// @include http*://*.steamgifts.com/*
// @include http*://*store.steampowered.com/*
// ==/UserScript==
// temporarily disabling isthereanydeal, until someone have time to fix it
// @include http*://*isthereanydeal.com/*
var estilo1 = GM_getResourceText ("metacritic.global.css");
GM_addStyle (estilo1);
var estilo2 = GM_getResourceText ("metacritic.base.css");
GM_addStyle (estilo2);
var estilo3 = GM_getResourceText ("metacritic.css");
GM_addStyle (estilo3);
$(function(){
// SEARCHING FOR GAMES
if (window.location.href.indexOf('getgamesgo.com/product/') > -1) {
full_ou_mini = 'full';
elementos = $('#pageTitle');
$("<style>.main_details, .side_details { display: inline-block; }</style>").appendTo(document.documentElement);
$('nav.mainTitle').removeClass('mainTitle').css({"border":"2px solid rgb(66, 127, 166)", "background":"none repeat scroll 0% 0% rgb(0, 0, 0)"});
}
if (window.location.href.indexOf('greenmangaming.com/s') > -1) {
full_ou_mini = 'full';
elementos = $('div#main > .prod_det');
$("<style>.main_details, .side_details { display: inline-block; }</style>").appendTo(document.documentElement);
$("<style>.metafull { display: table !important; }</style>").appendTo(document.documentElement);
$("div.wrapper").css({"min-width":"70%", "max-width":"90%"});
}
if (window.location.href.indexOf('isthereanydeal.com') > -1) {
full_ou_mini = 'mini';
elementos = $('div.title');
elementos.css({'border':'1px solid red'})
$("<style>.main_details, .side_details { display: inline-block; }</style>").appendTo(document.documentElement);
}
if (window.location.href.indexOf('nuuvem.com.br/produto/') > -1) {
full_ou_mini = 'full';
elementos = $('div.blockholder.right > .blockcontent > header > h2 > strong');
$("<style>.main_details, .side_details { display: inline-block; }</style>").appendTo(document.documentElement);
$("div.wrapper.pageholder").css({"min-width":"70%", "max-width":"90%"});
$("div.blockholder.right").css({"min-width":"70%", "max-width":"90%"});
}
if (window.location.href.indexOf('nuuvem.com.br/produtos') > -1) {
full_ou_mini = 'mini';
elementos = $('div.info > a.name');
$("<style>.main_details, .side_details { display: inline-block; }</style>").appendTo(document.documentElement);
$("<style>.main_details, .side_details { width: 250px; }</style>").appendTo(document.documentElement);
$("<style>div.metamini { float: left; }</style>").appendTo(document.documentElement);
$("div.wrapper").css({"max-width":"90%", "width":"auto"});
$("div#produtos").css({"display":"table"});
$("div.games").css({"width":"auto", "height":"auto"});
$("div.list > ul > li").css({"height":"52px", "overflow":"hidden"});
$("div.info").css({"min-width":"800px", "width":"auto"});
$("li div.purchase").css({"float":"right"});
}
if ((window.location.href.indexOf('steamcommunity.com/id/') > -1) && (window.location.href.indexOf('/wishlist') > -1)) {
full_ou_mini = 'mini';
elementos = $('div.wishlistRowItem > h4');
$("<style>.main_details, .side_details { display: inline-block; }</style>").appendTo(document.documentElement);
$("<style>.main_details, .side_details { width: 200px; }</style>").appendTo(document.documentElement);
$("<style>div.metamini { float: left; }</style>").appendTo(document.documentElement);
$("div.wishlistRow").css({"height":"auto", "overflow":"hidden", "width":"850px"});
$("div.bottom_controls").css({"position":"initial"});
}
if (window.location.href.indexOf('steamgifts.com') > -1) {
full_ou_mini = 'full';
elementos = $('.ajax_gifts > .post > .left > .title > a');
$("<style>.main_details, .side_details { display: inline-block; }</style>").appendTo(document.documentElement);
$("<style>div.ajax_gifts div.left { border: 1px dotted red; }</style>").appendTo(document.documentElement);
}
if (window.location.href.indexOf('store.steampowered.com/app') > -1) {
full_ou_mini = 'full';
elementos = $('.apphub_HeaderStandardTop > .apphub_AppName');
$("<style>.main_details, .side_details { display: inline-block; }</style>").appendTo(document.documentElement);
$("<style>.apphub_HeaderStandardTop { height: auto !important; background-size: 100% auto; }</style>").appendTo(document.documentElement);
}
// METACRITIC CONTENT
if (full_ou_mini == 'full') {
var inicio = /(?=<div class="summary_wrap">)/i;
var fim = '<div class="module critic_user_reviews">';
var classe = 'metafull';
}
else if (full_ou_mini == 'mini') {
var inicio = /(?=<div class="section product_scores">)/i;
var fim = '<div class="section product_details">';
var classe = 'metamini';
}
else {
alert('variable full_ou_mini not defined for this domain');
return;
}
// DOM
elementos.each(function() {
var elemjogo = $(this)
var jogo = elemjogo.text()
console.log('jogo encontrado: ' + jogo)
jogo = jogo.replace(/\(MAC|NA\)*$/i, "");
jogo = jogo.replace(/[\.,\/#!$%\^&\*;:{}=\_`'´"~()]/g, "")
jogo = $.trim(jogo).toLowerCase()
jogo = jogo.replace(/[\s\-]+/g, '-');
$(elemjogo).append("<div id='" + jogo + "' class='" + classe + "' style='display:inline-block; font-size:9px;' />")
requisicao = "http://www.metacritic.com/game/pc/" + encodeURIComponent(jogo)
conectar('GET', requisicao, respostametacritic)
function conectar(metodo, endereco, resposta, corpo) {
console.log('pesquisando no endereco: ' + endereco)
callback = function(xhr) { resposta(xhr) };
GM_xmlhttpRequest({
"method" : metodo,
"url" : endereco,
"onerror" : callback,
"onload" : callback,
"headers" : {'Content-Type' : 'application/x-www-form-urlencoded'},
"data" : corpo
});
}
function respostametacritic(detalhes) {
$("#" + jogo).html(detalhes.responseText.split(inicio)[1].split(fim)[0])
}
})
});