Last active
November 21, 2022 15:21
-
-
Save peruihkxt/00b62ff8f8d4c497e502cc204a23137f to your computer and use it in GitHub Desktop.
Show Dell Warranty link beside the serial number on Snipe-IT
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 Snipe-IT Asset List Warranty Link | |
// @namespace http://tampermonkey.net/ | |
// @version 0.3 | |
// @description try to take over the world! | |
// @author You | |
// @match https://cbnva.snipe-it.io/hardware | |
// @match https://cbnva.snipe-it.io/models/* | |
// @grant none | |
// @updateURL https://gist.github.com/JeremyLee/00b62ff8f8d4c497e502cc204a23137f/raw/SnipeITAssetListWarrantyLink.user.js | |
// @downloadURL https://gist.github.com/JeremyLee/00b62ff8f8d4c497e502cc204a23137f/raw/SnipeITAssetListWarrantyLink.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
window.hardwareWarrantyFormatter = function hardwareWarrantyFormatter(value, row) { | |
if((!row.manufacturer) || (typeof row.manufacturer.name !== "string") || row.manufacturer.name.toLowerCase().indexOf("dell") === -1) { | |
return value; | |
} else { | |
if(value === null || ("string" === typeof value && value.length === 0)) { | |
return '<a target="_blank" href="https://www.dell.com/support/home/us/en/04/product-support/servicetag/' + row.serial + '/warranty?ref=captchasuccess">Warranty</a>'; | |
} else { | |
return '<a target="_blank" href="https://www.dell.com/support/home/us/en/04/product-support/servicetag/' + row.serial + '/warranty?ref=captchasuccess">' + value + '</a>'; | |
} | |
} | |
}; | |
window.hardwareNameFormatterWithRemote = function hardwareNameFormatterWithRemote(value, row) { | |
var html = '' | |
if(row && row.custom_fields && row.custom_fields["Remote Access"] && row.custom_fields["Remote Access"].value) { | |
html += '<a href="st-business://com.splashtop.business?uuid=' + row.custom_fields["Remote Access"].value + '&sessiontype=remote"><img style="width:16px; height:16px;" src="https://theme.zdassets.com/theme_assets/294070/7205f6bf4ce931b326f56a3b0395092ca05dcc74.png"> </a>' | |
} | |
if (value) { | |
html += '<a href="https://cbnva.snipe-it.io/hardware/' + row.id + '"> ' + value + '</a>'; | |
} | |
return html; | |
}; | |
var table = $("#assetsListingTable"); | |
if(table.length == 0) { | |
table = $("#assetListingTable"); | |
} | |
var options = table.bootstrapTable('getOptions'); | |
options.columns[0].forEach(function(column) { | |
if(column.field==="warranty_months") { | |
column.formatter="hardwareWarrantyFormatter"; | |
} | |
}); | |
options.columns[0].forEach(function(column) { | |
if(column.field==="name") { | |
column.formatter="hardwareNameFormatterWithRemote"; | |
} | |
}); | |
table.bootstrapTable('refreshOptions', {}); | |
//debugger; | |
})(); |
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 Snipe-IT Serial Warranty Link | |
// @namespace http://tampermonkey.net/ | |
// @version 0.5 | |
// @description try to take over the world! | |
// @author You | |
// @match https://cbnva.snipe-it.io/hardware/* | |
// @grant none | |
// @updateURL https://gist.github.com/JeremyLee/00b62ff8f8d4c497e502cc204a23137f/raw/SnipeITAssetSerialWarrantyLink.user.js | |
// @downloadURL https://gist.github.com/JeremyLee/00b62ff8f8d4c497e502cc204a23137f/raw/SnipeITAssetSerialWarrantyLink.user.js | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var isDell = $("div#details div.row div.col-md-2:first-child:contains(Manufacturer)").next().text().toLowerCase().indexOf("dell") > -1 | |
if(isDell === true) { | |
var x = $("div#details div.row div.col-md-2:first-child:contains(Serial)") | |
for(var y in x) { | |
var serialElement = $(x[y]).next() | |
var serial = serialElement.text().trim() | |
serialElement.append(" <a target='_blank' href='https://www.dell.com/support/home/us/en/04/product-support/servicetag/" + serial + "/warranty?ref=captchasuccess'>Dell Warranty</a>") | |
} | |
} | |
var ra = $("div#details div.row div.col-md-2:first-child:contains(Remote Access)") | |
ra = ra.next() | |
var remoteAccessString = ra.text().trim() | |
if(remoteAccessString.length === 32) { | |
ra.html('<a href="st-business://com.splashtop.business?uuid=' + remoteAccessString +'&sessiontype=remote"><img style="width:16px; height:16px;" src="https://theme.zdassets.com/theme_assets/294070/7205f6bf4ce931b326f56a3b0395092ca05dcc74.png"> Splashtop</a>'); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment