Skip to content

Instantly share code, notes, and snippets.

@quietlynn
Created January 8, 2012 11:12
Show Gist options
  • Save quietlynn/1578029 to your computer and use it in GitHub Desktop.
Save quietlynn/1578029 to your computer and use it in GitHub Desktop.
Google+ Timetable
/*
Google+ Timetable => Get links of one's recent posts.
Copyright (C) 2012 Jingqin Lynn
Includes jQuery
Copyright 2011, John Resig
Dual licensed under the MIT or GPL Version 2 licenses.
http://jquery.org/license
Includes Sizzle.js
http://sizzlejs.com/
Copyright 2011, The Dojo Foundation
Released under the MIT, BSD, and GPL Licenses.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
// ==UserScript==
// @name Google+ Timetable
// @namespace http://project.quietmusic.org/2012/userscript/gplus/
// @description Get links of one's recent posts.
// @match https://plus.google.com/*
// ==/UserScript==
(function (name, url, main) {
'use strict';
//Use the <base> element to detect Google+ main page.
var base = document.querySelector('base');
if (!base || !base.href.match(/^https:\/\/plus\.google\.com(\/u\/\d+)?\/?/)) return;
var win = window;
if (typeof(unsafeWindow) != 'undefined') {
//Chrome V8 don't support unsafeWindow. Time for a hack.
if (window == unsafeWindow) {
var span = document.createElement('span');
span.setAttribute('onclick', 'return window;');
unsafeWindow = span.onclick();
}
win = unsafeWindow;
}
if (win.DependencyLoader.dependencyState(name) == win.DependencyLoader.Dependency.LOADING) {
main();
} else {
var dependencies = [
{ 'jQuery.gplus' : 'https://gist.github.com/raw/2645666/jquery.gplus.js' }
];
var me = {}; me[name] = url;
dependencies.push(me);
win.DependencyLoader.requireOrdered(dependencies,
null, function () {
win.DependencyLoader.require(name, main);
}
);
}
})(
'org.quietmusic.project.gplus.timetable',
'https://gist.github.com/raw/1578029/gplus.timetable.user.js',
function () {
'use strict';
var $ = window.jQuery;
$.gplus.page().dynamicSelect('profileNameContainer', function (n) {
n.append($("<input/>").attr("type", "button").val("T").click(function () {
var months = {};
$.gplus.page().find('postDateTime').eachElement(function (e) {
var link = e[0].href.replace(
/https:\/\/plus\.google\.com\/u\/\d+/,
"https://plus.google.com"
);
var date = e.publishDate();
var month = date.getMonth() + 1;
var day = date.getDate();
var days = months[month]
if(!days) days = months[month] = {};
var posts = days[day]
if(!posts) posts = days[day] = [];
posts.push(link);
});
var div = $('<div/>').css({
'position' : 'fixed',
'z-index' : '99999999',
'top' : '0',
'left' : '0',
'width' : '100%',
'height' : '100%',
'background-color' : 'white',
});
for (var m in months) {
var tbody = $("<tbody/>");
var table = $("<table/>").append(tbody);
for (var d in months[m]) {
var cell1 = $("<td/>").css("border-width", "1px").css("border-style", "solid").css("min-width", "30px");
cell1.text(d);
var cell2 = $("<td/>").css("border-width", "1px").css("border-style", "solid");
var tr = $("<tr/>").append(cell1).append(cell2);
var posts = months[m][d];
for (var i = 0; i < posts.length; i++) {
var a = $("<a/>");
a.attr("href", posts[i]).text(posts[i]);
cell2.append(a);
cell2.append($("<br/>"));
}
table.append(tr);
}
var p = $("<p/>");
p.text(m + "月");
div.append(p).append(table);
}
div[0].addEventListener('contextmenu', function (e) {
if (!e) e = window.event;
e.preventDefault();
div.remove();
}, false);
div.appendTo('body');
}));
});
});
@guotie
Copy link

guotie commented Jan 9, 2012

function的参数$和_是什么意思?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment