Reputation: 1149
I'm fighting to get a userscript to work on chrome. I know this question has been asked hundreds of times but I still can't get it to work...
// ==UserScript==
// @name SRH hide closed cases
// @namespace srhhideclosed
// @description For hiding appeals and reports that have been closed
// @include http://www.seriousroleplayinghell.com*
// @include http://seriousroleplayinghell.com*
// @include http://www.srh.im.com*
// @include http://srh.im.com*
// @version 1
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js
// ==/UserScript==
// Insert GM API for chrome
if (typeof GM_deleteValue == 'undefined') {
GM_addStyle = function(css) {
var style = document.createElement('style');
style.textContent = css;
document.getElementsByTagName('head')[0].appendChild(style);
}
GM_deleteValue = function(name) {
localStorage.removeItem(name);
}
GM_getValue = function(name, defaultValue) {
var value = localStorage.getItem(name);
if (!value)
return defaultValue;
var type = value[0];
value = value.substring(1);
switch (type) {
case 'b':
return value == 'true';
case 'n':
return Number(value);
default:
return value;
}
}
GM_log = function(message) {
console.log(message);
}
GM_openInTab = function(url) {
return window.open(url, "_blank");
}
GM_registerMenuCommand = function(name, funk) {
//todo
}
GM_setValue = function(name, value) {
value = (typeof value)[0] + value;
localStorage.setItem(name, value);
}
}
function toggleHidden(){
if(GM_getValue("SRHhidden",0) == 1){
GM_setValue("SRHhidden", 0);
}else{
GM_setValue("SRHhidden", 1);
}
hide(1000)
}
function hide(speed){
if(GM_getValue("SRHhidden",0) == 1){
$('s').closest('tr').fadeIn(speed);
}else{
$('s').closest('tr').fadeOut(speed);
}
}
if(document.title == "Serious Roleplaying Hell - Appeals" || document.title == "Serious Roleplaying Hell - Admin/Player Abuse Reports" ){
var TDHeads = document.getElementsByClassName("thead");
var Head = TDHeads[1];
var sp1 = document.createElement("div");
sp1.style.cssFloat = "right";
sp1.style.margin = "0 0 0 6px";
sp1.innerHTML = "<span class='smalltext'><strong>| <a id='hideToggle'>Hide/Show closed threads</a></strong></span>";
Head.insertBefore(sp1, Head.firstChild);
var toggle = document.getElementById('hideToggle');
toggle.addEventListener('click',toggleHidden,true);
var style = "#hideToggle:hover{cursor:pointer} #hideToggle{color:#ffffff;}"
GM_addStyle(style);
hide(0);
}
So what does it need to do, there is this forum that shows threads subjects striped if the thread is closed. For a reason I need to hide all the closed once so I can review only the open threads. I have this script running on Firefox, but @require
is not supported by Chrome.
I've tried How can I use jQuery in Greasemonkey scripts in Google Chrome? and How to play nicely with jQuery and Greasemonkey. But, I can get neither to work in Chrome. Anyone have some suggestions?
Upvotes: 1
Views: 1114