Skip to content

Instantly share code, notes, and snippets.

View creesch's full-sized avatar
💭
I am not actually sure...

creesch creesch

💭
I am not actually sure...
View GitHub Profile
@creesch
creesch / reddit.php
Created October 6, 2012 21:20
Reddit api frankenstein wrapper
<?php
/***************************************************************************
* Class name: Reddit
* Description: Frankenstein combination of https://github.com/jcleblanc/reddit-php-sdk
* and https://gist.github.com/3845707
* Goal: Expand on Flotwig's code to be able to use data only avalaible while logged in.
* Usage:
* $reddit->urlApi('message/inbox/')
***************************************************************************/
class reddit{
@creesch
creesch / nl.yml
Created November 29, 2012 21:15
Dutch translation
# Dutch translation, most is correct. Might want a second opionion
# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
nl:
navigation:
headers:
general: "Algemeen"
information: "Informatie"
status: "Status"
rules: "Regels en Richtlijnen"
@creesch
creesch / search_user.php
Created December 11, 2012 08:29
basic framework to later convert into proper search tool
<?php
// example usage:
// redditApi('user/creesch'); will return an array with information about me
// redditApi('r/theoryofreddit'); will return an array of info about r/breakingbad
function redditApi($call,$domain='www.reddit.com') {
$url = 'http://' . $domain . '/' . $call;
if (function_exists('curl_init')) { // not all PHP installations have cURL
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($ch,CURLOPT_USERAGENT,'/u/creesch'); // Needed for stats and identifing scripts that do not behave, change to something to unique.
body .content .sitetable .thing.spam, body .sitetable .thing.spam.deleted.link.self {
border: solid 2px #FA8072 !important;
}
.comments-page .thing.spam > .entry {
display: none;
}
/* Next 4 sections make deleted messages less noticeable -djimbob*/
form.grayed, form.grayed ~ ul.flat-list.buttons { display: none }
p.tagline > a.expand:first-child + em:after, div.collapsed > a.expand:first-child + em:after
{
visibility: visible;
font-weight: bold;
content: "Comment deleted or removed"
}
p.tagline > a.expand:first-child + em, div.collapsed > a.expand:first-child + em
// ==UserScript==
// @name reddit.com - Realtime Reddit
// @namespace v2
// @include *.reddit.com/r/*/about/unmoderated*
// @include *.reddit.com/r/*/about/probation*
// @include *.reddit.com/r/*/comments/
// @include *.reddit.com/r/*/comments
// @include *.reddit.com/comments/
// @include *.reddit.com/comments
// @include *.reddit.com/user/*
$.getJSON(jsonurl).done(function (data, status, jqxhr) {
console.log(status);
console.log(jqxhr.getAllResponseHeaders());
console.log(jqxhr.getResponseHeader('x-ratelimit-remaining'));
});
$('.comments-page .comment .flat-list.buttons').each(function () { // this targets each flat-list belonging to comments on a comment page.
$(this).append('<li><a class="view-source" href="javascript:void(0)">view source</a></li>'); // it then adds the view sourc button in the belonging function
});
$('body').on('click', '.view-source', function () { // On clicking of the view source button we do what we want to do. Note that we start with body since that is a constant dom element. If you try to target added dom elements directly it will not work.
var $this = $(this), // We posisbly want to reuse $(this), it is cleaner to define jquery objects you want to reuse.
$parentThing = $this.closest('.thing'),
thingId = $parentThing.attr('data-fullname'); // we need an id to throw at the api, luckily it is is present in the html.
if($parentThing.find('#box-' + thingId).length) { // Lets see if we already did do this before.
div#header-bottom-left {
padding-top: 20px;
}
#header-img {
max-height: 40px !important;
}
#header-img-a {
margin: 0 !important;
.sitetable .thing.stickied {
border: dashed 10px rgb(255, 92, 0) !important;
outline: solid 5px red;
}
.sitetable .thing.stickied .title {
font-size: 45px !important;
}
.sitetable .thing.stickied .title a {
color: rgb(90, 165, 75) !important;
}