Skip to content

Instantly share code, notes, and snippets.

@fisknils
fisknils / greasemonkey functions
Last active August 29, 2015 14:21
just some javascript- functions I find myself often using for greasemonkey- scripts
// Some convenience- functions for removing elements
function removeElementByXpath(xpath) {
return removeElement(getElementByXpath(xpath));
}
function getElementByXpath(xpath) {
return document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
}
@fisknils
fisknils / gist:1ce030dee1bb259a42c2
Last active November 13, 2016 00:03
This userscript removes any listing marked as "Freemium" and "Free*", on alternativeto.net when the site's filter is set to free.
// ==UserScript==
// @name Alternativeto.net ~Free != Free
// @namespace https://gist.github.com/fisknils
// @version 0.1
// @description This script removes any listing marked as "Freemium" and "Free*", when the site's filter is set to free.
// @author Fisknils
// @match *://alternativeto.net/*?license=free*
// @grant none
// ==/UserScript==
{
"måndag":{"butik":"stängt","hämtningar":"09-16"},
"tisdag":{"butik":"16-18","hämtningar":"09-16"},
"onsdag":{"butik":"14-18","hämtningar":"09-16"},
"torsdag":{"butik":"stängt","hämtningar":"09-16"},
"fredag":{"butik":"stängt","hämtningar":"09-15"},
"lördag":{"butik":"10-14","hämtningar":"10-14"},
"söndag":{"butik":"stängt","hämtningar":"stängt"}
}
@fisknils
fisknils / stringhex.php
Created August 19, 2015 17:58
for converting each character in a string to a string of hex values
<?PHP
// returns the hex value of a single character (if a string is supplied, only the first character will be processed)
function charhex($c) {
return dechex(ord($c[0]));
}
// returns the hex values of each character in string with optional delimiter
function stringhex($s,$delimiter="") {
#include <Misc.au3>
#include <Array.au3>
AutoItSetOption("PixelCoordMode",2)
AutoItSetOption("MouseCoordMode",2)
HotKeySet("{ESC}", "Terminate")
HotKeySet("{PAUSE}", "Toggle")
$enabled = True
// patchjob javascript to parse the contents of
// https://www.coinbase.com/accounts/*#
// since there's no export
// work in progress
// this just gets each line's source and target currency + volumes and prints it as a multi- dimensional object
// into the developer console
// you should NEVER run ANY scripts on ANY authenticated page unless you understand EXACTLY what the code does
// OR if you WANT trouble.
// including jquery in your electron body.
//
// https://stackoverflow.com/questions/32621988/electron-jquery-is-not-defined
// https://stackoverflow.com/a/37480521/4023754
<!-- Insert this line above script imports -->
if (typeof module === 'object') {window.module = module; module = undefined;}
<!-- normal script imports etc -->
[
// ==UserScript==
// @name My Elastic Userscript
// @namespace https://gist.github.com/fisknils
// @version 0.1
// @description Skeleton userscript with maybe a bit too much included.
// @author fisknils
// @include http*
// @require https://code.jquery.com/jquery-2.2.4.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/preact/8.2.6/preact.js
// @require
(function(){
/* returns an array containing the attr values of matching elements */
jQuery.fn.extend({
eachattr: function(attr){
let r = [];
$(this).each(function(){
r.push($(this).attr(attr));
});
return r;
}
(()=>{
const localStorage_extension = (function(){
this._get = (label=>{
return JSON.parse(localStorage.getItem(label));
});
this._put = ((label,items)=>{
return localStorage.setItem(label,JSON.stringify(items));
});