Skip to content

Instantly share code, notes, and snippets.

@grampelberg
Created April 9, 2018 13:19
Show Gist options
  • Save grampelberg/5449104d3c353282c65c574dd4367d1c to your computer and use it in GitHub Desktop.
Save grampelberg/5449104d3c353282c65c574dd4367d1c to your computer and use it in GitHub Desktop.
pinboard tampermonkey
// ==UserScript==
// @name New Userscript
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://pinboard.in/u:pyronicide/t:daily
// @grant GM_openInTab
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js
// ==/UserScript==
$(function() {
var day = new Date().getDay();
var opener = {
button: function() {
$("<button>Open in tabs</button>").prependTo("#right_bar").click(opener.in_tabs);
},
in_tabs: function() {
$(".bookmark").each(function(k, e) {
var rules = {
"mwf": function() {
return day == 1 || day == 3 || day == 5;
},
"m-f": function() {
return day > 0 && day < 6;
}
};
var everyday = true;
var text = $(e).find(".tag").text();
$.each(rules, function(k, v) {
if (text.indexOf(k) == -1) return;
everyday = false;
if (!v()) return;
opener.new_tab($(e).find(".bookmark_title").attr("href"));
});
if (!everyday) return;
opener.new_tab($(e).find(".bookmark_title").attr("href"));
});
},
new_tab: function(href) {
GM_openInTab(href, { 'insert': true });
}
};
if (location.href.match(/t:/)) opener.button();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment