Skip to content

Instantly share code, notes, and snippets.

@pyhedgehog
Last active August 26, 2015 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pyhedgehog/92b4dd8088657ce78208 to your computer and use it in GitHub Desktop.
Save pyhedgehog/92b4dd8088657ce78208 to your computer and use it in GitHub Desktop.
LJ title revert
// ==UserScript==
// @name LJ title revert
// @id ljTitleRevert@pyhedgehog.github.com
// @namespace https://gist.github.com/pyhedgehog/
// @description Revert recent changes on livejournal blog pages that brings ljuser to end of title.
// @homepage https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/
// @downloadURL https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/raw/ljTitleRevert.user.js
// @updateURL https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/raw/ljTitleRevert.meta.js
// @include http://*.livejournal.com/*.html
// @include http://users.livejournal.com/*/*.html
// @include http://*.livejournal.com/*.html?*
// @include http://users.livejournal.com/*/*.html?*
// @version 6
// @grant none
// @run-at document-start
// @noframes
// ==/UserScript==
// ==UserScript==
// @name LJ title revert
// @id ljTitleRevert@pyhedgehog.github.com
// @namespace https://gist.github.com/pyhedgehog/
// @description Revert recent changes on livejournal blog pages that brings ljuser to end of title.
// @homepage https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/
// @downloadURL https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/raw/ljTitleRevert.user.js
// @updateURL https://gist.github.com/pyhedgehog/92b4dd8088657ce78208/raw/ljTitleRevert.meta.js
// @include http://*.livejournal.com/*.html
// @include http://users.livejournal.com/*/*.html
// @include http://*.livejournal.com/*.html?*
// @include http://users.livejournal.com/*/*.html?*
// @version 6
// @grant none
// @run-at document-start
// @noframes
// ==/UserScript==
(function ljTitleRevert() {
if(!document.title) {
//console.log('ljTitleRevert: postpone');
return window.setTimeout(ljTitleRevert, 1000);
}
//console.log('ljTitleRevert: start');
//var re1 = /^https?:\/\/([^./]*)\.livejournal\.com\/[^/]*\.html(?:\?format=light)?$/;
//var re2 = /^https?:\/\/users\.livejournal\.com\/([^./]*)\/[^/]*\.html(?:\?format=light)?$/;
var re1 = /^https?:\/\/([^./]*)\.livejournal\.com\/[^/]*\.html(?:\?.*)?$/;
var re2 = /^https?:\/\/users\.livejournal\.com\/([^./]*)\/[^/]*\.html(?:\?.*)?$/;
var m = re1.exec(document.location.href);
if(!m) {
//console.log('ljTitleRevert: !re1');
m = re2.exec(document.location.href);
}
if(!m) {
//console.log('ljTitleRevert: !re2');
return;
}
var ljuser = m[1].replace(/-/g, '_');
if(document.title.endsWith(': '+ljuser)) {
//console.log('ljTitleRevert: title.endsWith colon+'+ljuser);
document.title = ljuser+': '+(document.title.replace(': '+ljuser, ''));
return;
}
if(document.title.endsWith(' - '+ljuser)) {
//console.log('ljTitleRevert: title.endsWith minus+'+ljuser);
document.title = ljuser+': '+(document.title.replace(' - '+ljuser, ''));
return;
}
//console.log('ljTitleRevert: end');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment