Last active
February 1, 2017 22:21
-
-
Save noromanba/999628af9a744e593beb3fe3e1d38413 to your computer and use it in GitHub Desktop.
canonical openload.co for UserScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name OL canonical | |
// @namespace http://noromanba.flavors.me | |
// @description canonical openload.co for UserScript | |
// @include *://openload.co/f/* | |
// @include *://openload.co/embed/* | |
// @include *://oload.tv/f/* | |
// @include *://oload.tv/embed/* | |
// @grant none | |
// @noframes | |
// @run-at document-start | |
// @version 2017.2.1.0 | |
// @homepage https://gist.github.com/noromanba/999628af9a744e593beb3fe3e1d38413 | |
// @downloadURL https://gist.github.com/noromanba/999628af9a744e593beb3fe3e1d38413/raw/ol-canonical.user.js | |
// @license MIT License http://nrm.mit-license.org/2017 | |
// @author noromanba http://noromanba.flavors.me | |
// @icon https://upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Bird_template.svg/240px-Bird_template.svg.png | |
// ==/UserScript== | |
// Icon (PD by Art-top, Nesusvet and Urutseg) | |
// https://commons.wikimedia.org/wiki/File%3ABird_template.svg | |
// Devel | |
// https://gist.github.com/noromanba/999628af9a744e593beb3fe3e1d38413 | |
// FIXME Tampermonkey favicon access | |
// ol.link blacklist of Google Safe Browsing | |
// and Tampermonkey everytime greedy favicon access, | |
// so unsafe alert on Dashboard everytime WTH | |
// @include *://ol.link/f/* | |
// @include *://ol.link/embed/* | |
// TODO | |
// - /embed/ handling | |
// - ol.link handling | |
// - Chrome do not change location | |
// - Firefox can use location | |
// - refactoring | |
// - set icon | |
(() => { | |
'use strict'; | |
if (location.hostname === 'oload.tv' || | |
location.hostname === 'ol.link') { | |
location.hostname = 'openload.co'; | |
} | |
const title = (() => { | |
return (document.querySelector('head meta[name="description"][content]') || {}).content || | |
(document.querySelector('head meta[name="og:title"][content]') || {}).content || | |
(document.querySelector('head meta[name="twitter:title"][content]') || {}).content || | |
document.title.slice(0, document.title.lastIndexOf(' | openload')); | |
})(); | |
const canonURL = (() => { | |
const url = (document.querySelector('meta[name="og:url"][content]') || {}).content; | |
let canon = new URL(url); | |
// ol std syntax | |
// https://openload.co/f/<ID>/ | |
// https://openload.co/f/<ID> | |
canon.pathname = canon.pathname.match(/\/f\/[\w\-]+/) + '/'; | |
return canon.href; | |
})(); | |
history.pushState(null, null, canonURL + title.replace(/\s/g, '_')); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment